How to show UI window with edit line marked and ready to paste information in it?

4 views (last 30 days)
I am copying a window sequence and I dont know how to do two things:
First, I dont to how to begin the window with the selected text in the edit line.
This is the code for that window:
function window_7
% Create and then hide the UI as it is being constructed.
f = figure('Visible','off','Position',[360,500,450,185],'NumberTitle','off','ToolBar','none','MenuBar','none','Color',[0.95 0.95 0.95]);
% Construct the components.
hOk = uicontrol('Style','pushbutton','String','Ok','Position',[350,140,70,25],'Callback',@Okbutton_Callback);
hCan = uicontrol('Style','pushbutton','String','Cancel','Position',[350,105,70,25],'Callback',@Canbutton_Callback);
hEdit = uicontrol('Style','edit','String','Enter path','Position',[25 50 400 20]);
htext = uicontrol('Style','text','String','Enter the complete path','Position',[-130,120,450,50]);
% Change font size
set(hOk,'FontSize',10);
set(hCan,'FontSize',10);
set(htext,'FontSize',11);
% Initialize the UI.
% Change units to normalized so components resize automatically.
f.Units = 'normalized';
hOk.Units = 'normalized';
hCan.Units = 'normalized';
% Assign the a name to appear in the window title.
f.Name = 'Macro Message';
% Move the window to the center of the screen.
movegui(f,'center')
% Make the window visible.
f.Visible = 'on';
function Okbutton_Callback(source,eventdata)
close
end
function Canbutton_Callback(source,eventdata)
close
end
end
Image 1.png shows how my window looks (leftside) and also shows how it should look like (rightside). See how the window from the rightside begins with the text in the edit row already marked in blue? It is ready for some one to paste a path. I dont know how to do that.
And second, I dont know how to make "radiobutton" to allow to select just one at a time
This is the code for that window:
function window_6
% Create and then hide the UI as it is being constructed.
f = figure('Visible','off','Position',[360,500,450,185],'NumberTitle','off','ToolBar','none','MenuBar','none','Color',[0.95 0.95 0.95]);
% Construct the components.
hOk = uicontrol('Style','pushbutton','String','Ok','Position',[200,15,70,25],'Callback',@Okbutton_Callback);
hRb = uicontrol('Style','radiobutton','String','PHX-Reichert-Jung 500x-U50 Camera','Value',1,'Position',[30 125 450 20]);
hRb2 = uicontrol('Style','radiobutton','String','HCMO-Axiovert 500x','Value',0,'Position',[30 105 450 20]);
hRb3 = uicontrol('Style','radiobutton','String','HCMO-Observer D1 500x','Value',0,'Position',[30 85 450 20]);
hRb4 = uicontrol('Style','radiobutton','String','Greer-Olympus BX51M 500x','Value',0,'Position',[30 65 450 20]);
hRb5 = uicontrol('Style','radiobutton','String','METL-500x','Value',0,'Position',[30 45 450 20]);
htext = uicontrol('Style','text','String','Please select capture area/scope and magnification','Position',[3,140,450,35]);
% Change font size
set(hOk,'FontSize',10);
set(hRb,'FontSize',11);
set(hRb2,'FontSize',11);
set(hRb3,'FontSize',11);
set(hRb4,'FontSize',11);
set(hRb5,'FontSize',11);
set(htext,'FontSize',11);
% Initialize the UI.
% Change units to normalized so components resize automatically.
f.Units = 'normalized';
hOk.Units = 'normalized';
% Assign the a name to appear in the window title.
f.Name = 'Macro Message';
% Move the window to the center of the screen.
movegui(f,'center')
% Make the window visible.
f.Visible = 'on';
function Okbutton_Callback(source,eventdata)
close; window_7;
end
end
Image 2.png shows how it looks. See it lets you select multiple options at a time? I dont want it to do that and I dont know how to stop it.
Thank you for your time

Answers (1)

Walter Roberson
Walter Roberson on 4 Sep 2015
For the second part, look at uibuttongroup() as it ensures that only one button is selected.

Categories

Find more on Interactive Control and Callbacks 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!