How would i write a code for my pushbutton in a gui that flips or changed the background color on the pushbutton back to original?

I am creating the memory game using a gui and im using multiple pushbuttons to display the different colors. When i click on the button it does change to a different color but i need it to go back to the original color if the two cards chosen are not the same. How could i do that?

답변 (2개)

Store a variable with value 1. Then simply negate it everytime you run the callback function. And using an if-else statement you can change colours. To get the default color of pushbutton use get(handles.pushbutton,'BackgroundColor'). I hope its clear.

댓글 수: 1

This is what i had for my push buttons set(handles.pushbutton3,'BackgroundColor','blue') x3 = get(hObject,'Background')
could you give me an example of how to store that variable and use the if statement?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Just for fun에 대해 자세히 알아보기

제품

태그

질문:

2014년 4월 16일

답변:

2014년 4월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by