Creating Graphical User Interfaces | ![]() ![]() |
Specify the Location of the Dialog
The dialog application M-file accepts an input argument that specifies where to display the dialog. This enables the Close button callback to locate the dialog with respect to the main application window. The argument is a two-element vector containing the left and bottom offsets from the right and lower edge of the screen, in character units. The Close button callback determines these values.
Preventing Figure Flash
In some cases, repositioning the dialog's figure may cause it to "flash" on the screen in its current position before the set
command repositions it. To prevent this effect, save the dialog with it's figure Visible
property set to off
. You can then set the Visible
property to on
after specifying the position. Note that you must specify the Position
property before setting visibility to on.
if nargin == 1 pos_size = get(fig,'Position'); pos = varargin{1}; if length(pos) ~= 2 error('Input argument must be a 2-element vector') end new_pos = [pos(1) pos(2) pos_size(3) pos_size(4)]; set(fig,'Position',new_pos,'Visible','on') end
![]() | Launch the Dialog | Wait for User Response | ![]() |