function Test_UI_forums
scrsz = get( groot, 'ScreenSize' );
figure( 'Name', 'My Figure',...
'Position', [scrsz(3)/2-215 scrsz(4)/2-165 430 320],...
'Resize', 'off',...
'NumberTitle','off',...
'Toolbar', 'none',...
'Menu', 'none' );
h.value1 = uicontrol( 'Style', 'Edit',...
'String', '50',...
'HorizontalAlignment', 'Right',...
'Position', [20 265 60 25],...
'Callback', @value1_callback );
h.value1_text = uicontrol( 'Style', 'Text',...
'String', 'Value 1',...
'HorizontalAlignment', 'Left',...
'Position', [85 265 120 20] );
h.value2 = uicontrol( 'Style', 'Edit',...
'String', '5',...
'HorizontalAlignment', 'Right',...
'Position', [20 235 60 25],...
'Callback', @value2_callback );
h.value2_text = uicontrol( 'Style', 'Text',...
'String', 'Vaule 2',...
'HorizontalAlignment', 'Left',...
'Position', [85 235 120 20] );
hBut_ok = uicontrol( 'style', 'pushbutton',...
'Position', [270 10 70 25],...
'String', 'OK',...
'Callback', @cBut_ok );
hBut_cancel = uicontrol( 'style', 'pushbutton',...
'Position', [350 10 70 25],...
'String', 'Cancel',...
'Callback', @cBut_cancel );
uiwait;
end
function value1_callback( hObject, eventdata )
Value1 = str2double( get( hObject, 'String' ) );
if isnan( Value1 )
errordlg( 'You must enter a numeric value', 'Invalid input', 'Modal' );
return
else
display( Value1 );
end
end
function value2_callback( hObject, eventdata )
Value2 = str2double( get( hObject, 'String' ) );
if isnan( Value2 )
errordlg( 'You must enter a numeric value', 'Invalid input', 'Modal' );
return
else
display( Value2 );
end
end
function cBut_ok( hObject, eventdata )
close( gcf );
end
function cBut_cancel( hObject, eventdata )
delete( gcf );
end