Filter löschen
Filter löschen

How to add images on a pusbutton

4 Ansichten (letzte 30 Tage)
Jethro
Jethro am 29 Jan. 2012
Hi everybody!
I'd like to show the action of pressing pushbutton. I explain my problem: I created two images.
and
The "standard" image is the first one. I'd like to change it with the second one while pressing, just for few seconds, and after to return at the standard one... Is it possible? How can I do it??
There's the possibility to set pushbutton background as transparent??
Thanks!

Akzeptierte Antwort

Grzegorz Knor
Grzegorz Knor am 30 Jan. 2012
You can set images in this way:
function test1
i1 = imread('http://img818.imageshack.us/img818/7208/03close.png');
i2 = imread('http://img843.imageshack.us/img843/5276/03closeb.png');
button = uicontrol('style','pushbutton','position',[10 10 55 55],'callback',@b_clbck);
set(button,'cdata',i1)
function b_clbck(src,event)
set(button,'cdata',i2)
pause(2)
set(button,'cdata',i1)
end
end
  1 Kommentar
Jethro
Jethro am 30 Jan. 2012
Thank you so much! I did not know the pause function! Thanks a lot!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by