Wait for user input after pressing button

5 ビュー (過去 30 日間)
monkey_matlab
monkey_matlab 2016 年 4 月 20 日
回答済み: Meade 2016 年 4 月 20 日
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 Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by