Wait for user input after pressing button

5 次查看(过去 30 天)
Hello,
I created a "OK" button using the guide template in Matlab. Here is the code:
function varargout = prompt11(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @prompt11_OpeningFcn, ...
'gui_OutputFcn', @prompt11_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function prompt11_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = prompt11_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function pushbutton1_Callback(hObject, eventdata, handles)
function edit1_Callback(hObject, eventdata, handles)
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
How can I go about pausing my program until the user hits the "OK" button?
My code looks like this:
prompt11
my code
my code
my code

回答(1 个)

Meade
Meade 2016-4-20
  1. The GUIDE program creates guis using both an *.m file (what you posted) and a *.fig file (you did not post). You'd need to upload both in order for anyone to recreate your error.
  2. Good news though, your issue seems simple: Check out the uiwait and uiresume commands. Call uiwait at the end of the Main Fcn, then uiresume in the pushbutton fcn

类别

Help CenterFile Exchange 中查找有关 Entering Commands 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by