Wait for user input after pressing button

6 Ansichten (letzte 30 Tage)
monkey_matlab
monkey_matlab am 20 Apr. 2016
Beantwortet: Meade am 20 Apr. 2016
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

Antworten (1)

Meade
Meade am 20 Apr. 2016
  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

Kategorien

Mehr zu Entering Commands finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by