Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Can I use a function as a conditional statement?

1 visualización (últimos 30 días)
Kristen O'Mara
Kristen O'Mara el 5 de Mzo. de 2018
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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.

Respuestas (0)

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by