MATLAB: Gui run command only if another input has been done

guiiflistboxpushbutton

Good Morning I have created a GUI with various push_buttons and list-boxes. I want to run, for example, a command from a list-box only if pushbutton2 has executed (Otherwise, in fact, it gives me an error and I cannot keep selecting other buttons)
It should be something lke:
if-----> got value of pushbutton2
run listbox1
else
(don't run)
I know it's a bit rough, but I'm still a Noob!

Best Answer

You could use a global variable.
In your OpeningFcn(), have this:
global pushButton2Pushed;
pushButton2Pushed = false;
In your pushButton2_Callback(), have this:
global pushButton2Pushed;
pushButton2Pushed = true;
In any other function where you want to check if push button 2 has been pushed, have this:
global pushButton2Pushed;
if pushButton2Pushed
% Do something
end