Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Can I use a function as a conditional statement?

1 Ansicht (letzte 30 Tage)
Kristen O'Mara
Kristen O'Mara am 5 Mär. 2018
Geschlossen: MATLAB Answer Bot am 20 Aug. 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.

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by