Page 1 of 1
[4.20 Mac] ImageButton, 2nd Image for pressed-state
Posted: Tue May 27, 2008 3:47 pm
by jamirokwai
Dear Folks,
I tried to code an ImageButton with two images for pressed and not-pressed-state like this:
The images are embedded into the executable, and exist. The size is also correct for both.
Code: Select all
ImageGadget(0,0,0,20,20,ImageID(1))
SetGadgetAttribute(0, #PB_Button_PressedImage, ImageID(2))
The image does not change when clicking on the Button. It always displays the first image.
Is my code wrong?
Or does the Mac-Version not function like expected?
Do I have to manually change the image after catching the event?
Thanks in advance for comments!
Regards,
JamiroKwai
Posted: Tue May 27, 2008 4:14 pm
by Fluid Byte
This works for me (tested with 4.20f):
Code: Select all
CreateImage(0,130,25)
StartDrawing(ImageOutput(0))
Box(0,0,130,25,RGB(255,0,0))
StopDrawing()
CreateImage(1,130,25)
StartDrawing(ImageOutput(1))
Box(0,0,130,25,RGB(0,0,255))
StopDrawing()
OpenWindow(0,0,0,320,240,"void")
CreateGadgetList(WindowID(0))
ButtonImageGadget(0,10,10,130,25,ImageID(0))
SetGadgetAttribute(0, #PB_Button_PressedImage, ImageID(1))
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
[4.20 Mac] ImageButton, 2nd Image for pressed-state
Posted: Tue May 27, 2008 5:02 pm
by jamirokwai
Thanks.
The error simply was... ImageGadget does not support a second image
when using #PB_Button_PressedImage...
It works with ButtonImageGadget as you suggested.
Bummer
edit: I changed my code to use ImageGadget and change the image
manually within the event-loop using
Code: Select all
SetGadgetState(#gadget, ImageID(#2ndstate)) ; pressed
When clicked again, it is changed to the not-pressed image:
Code: Select all
SetGadgetState(#gadget, ImageID(#1ststate)) ; not-pressed
No score for style, but it works... Maybe somebody has as suggestion?
Posted: Tue May 27, 2008 5:35 pm
by Trond
I have a suggestion: if you want a button, use a button, not an image gadget.
Posted: Tue May 27, 2008 8:25 pm
by Fluid Byte
Well, I guess he want's a customized button ...
[4.20 Mac] ImageButton, 2nd Image for pressed-state
Posted: Tue May 27, 2008 10:26 pm
by jamirokwai
Fluid Byte wrote:Well, I guess he want's a customized button ...
Gotcha

or, better: Got-Me. That's the point: customized...
It works now as I'd wanted it to work like...
The MacOS-Gadgets are not satisfying, aren't they? Every gadget has its own border.
Posted: Wed May 28, 2008 4:01 pm
by Trond
Let me guess: you made your application inaccessible to any users who can't(/won't) use a mouse, and destroyed screenreader compatibility (for visually impaired) at the same time?
Not quite, but almost
Posted: Thu May 29, 2008 11:36 am
by jamirokwai
Trond wrote:Let me guess: you made your application inaccessible to any users who can't(/won't) use a mouse, and destroyed screenreader compatibility (for visually impaired) at the same time?
Not yet, Trond... But nearly... Just checking some possibilities of Gadgets.
As a matter of fact, I misplanned the GUI of my program, and have to re-code everything...

Now I will use panels with more space for every option. Hence: more usable for impacted people. In the end, I will add keyboard-shortcuts where usefull...