Prevent the movement of a figure with GUIDE
6 views (last 30 days)
Show older comments
Hello,
I am working with Matlab R2015a and use GUIDE to create my interface. When I launch my interface, a general figure contains buttons, text boxes, etc. What I wish is to prevent the movement of this general figure. Why? Because by clicking on a pushbutton, I can switch into another general figure (as if it was 2 tabs of a same figure). And I don't want any user move this general figure.
Thank you for your help. Best regards.
2 Comments
Accepted Answer
Guillaume
on 8 Jul 2015
If you mean to prevent the user from moving the whole figure window, that cannot be done in matlab. I'm not even sure you could do it by accessing the underlying java window.
The moving of the window is handled by the OS itself, so you would have to intercept the WM_MOVE event to stop the window from moving. Matlab does not give you access to that.
In any case, it's a very bad idea to prevent the user from moving windows. You should never try to prevent the user from doing things that are naturally expected to work, like moving windows. The end result is usually that the user gets fed up by unexpected behaviour and either try to defeat your restrictions or give up using your program.
To solve your problem, you only use one figure window and either have a uitabgroup with two tabs, or two uipanels whose visibility you toggle. The user can then move the figure window where they want without affecting any of your drawing.
More Answers (1)
Lincoln Emilio Bowen Aguayo
on 8 Jul 2015
In this way you can make a GUI, and the user cannot modify your interface:
function tabbedGUI()
hFig = figure('Menubar','none', 'Position', [25 50 1250 550]);
set (gcf, 'units', 'normalized', 'outerposition', [0 0 1 1]);
s = warning('off', 'MATLAB:uitabgroup:OldVersion');
hTabGroup = uitabgroup('Parent',hFig);
warning(s);
hTabs(1) = uitab('Parent',hTabGroup, 'Title','Opcion 1');
hTabs(2) = uitab('Parent',hTabGroup, 'Title','Opción 2');
set(hTabGroup, 'SelectedTab',hTabs(1));
uicontrol ('Style', 'pushbutton',...
'String', 'Compute',...
'BackgroundColor', [.5 .5 .5],...
'Position', [500 500 100 50],...
'Callback', @ComputeCallback,...
'Parent', hTabs(1));
function ComputeCallback (src, evt)
end
end
%
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!