GUI development: input dialog box fitting into sub-panel of panel

2 views (last 30 days)
Hello! I would like to create an input dialog box which gathers info from the user. The problem I am facing is that I would like it to fit into a sub-panel, part of a bigger panel. How can I do that?
I have tried to add it as a parent of a previously created panel, but it doesn't seem to work.
Option 1 does create it in a separate window, option 2 doesn't work (see attached code).
% Main Window
%================
figure('MenuBar','none','Name','My_GUI_w_PopupMenus','NumberTitle','off','Position',[400,400,1000,600]);
% uicontrol('Style','frame','Position',[20 400 300 180],'foregroundcolor',[1 0 0]);
% uipanel('Style','frame','Position',[20 400 30 18],'foregroundcolor',[1 0 0]);
% uipanel('Title','UI Panel 1','Position', [157.6 30.308 62.4 12.615],'Color');
% Sub-windows
%==============
% Main left window
hp = uipanel('Title','Array creation','FontSize',9,'BackgroundColor','white','Position',[0.02 0.04 0.4 0.92]);
% Sub-window 1
hsp = uipanel('Parent',hp,'Title','Basic constants','FontSize',8,'Position',[0.04 0.7 0.9 0.275]);
% Sub-window 2
hsp = uipanel('Parent',hp,'Title','Lattice type:','FontSize',8,'Position',[0.04 0.4 0.9 0.275]);
% dialog box gathers user's input
dlg_title = 'Input';
num_lines = 1;
def = {'20','hsv'};
% % option 1
% answer = inputdlg({'Enter matrix size:','Enter colormap name:'},dlg_title,num_lines,def,[400,200]);
% option 2
answer = inputdlg('Parent',hp,{'Enter matrix size:','Enter colormap name:'},dlg_title,num_lines,def,[400,200]);
I am new to GUI development so it might just be a very stupid question :)

Answers (1)

Walter Roberson
Walter Roberson on 16 Jul 2015

Categories

Find more on Startup and Shutdown 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!