Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Can I use a function as a conditional statement?

1 vue (au cours des 30 derniers jours)
Kristen O'Mara
Kristen O'Mara le 5 Mar 2018
Clôturé : MATLAB Answer Bot le 20 Août 2021
I'm working with my first GUI using the guide and I need to make a GUI with two pushbuttons. When pushbutton 1 is pressed, pushbutton 2 must display 'push me' and turn red. When either button is pressed, it should go back to being a white button with no text. In my current function, pushbutton 2 turns red and says 'push me' correctly and turns white with no text when you click it. However, I can't figure out how to get pushbutton 2 tow turn white with no text when pushbutton one is pressed. I tried using the call to that function in a conditional statement but I don't think you can do that.
Here is what I tried with the conditional statement:
function pushbutton1_Callback(hObject, eventdata, handles)
handles.pushbutton2.BackgroundColor = [1 0 0];
handles.pushbutton2.String = 'push me';
if pushbutton1_Callback(hObject, eventdata, handles) &&handles.pushbutton2.BackgroundColor = [1 0 0] &&
handles.pushbutton2.String = 'push me'
handles.pushbutton2.BackgroundColor = [1 1 1];
handles.pushbutton2.String = ' ';
end
I did this because in the code for the GUI there is a comment that says
% --- Executes on button press in pushbutton1.
Also I'm sure there is a better way to hide the text on the button than setting the string to a bunch of spaces, that was just my first thought.

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by