[4.20 Mac] ImageButton, 2nd Image for pressed-state

Just starting out? Need help? Post your questions and find answers here.
jamirokwai
Enthusiast
Enthusiast
Posts: 796
Joined: Tue May 20, 2008 2:12 am
Location: Cologne, Germany
Contact:

[4.20 Mac] ImageButton, 2nd Image for pressed-state

Post 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
Regards,
JamiroKwai
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post 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
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
jamirokwai
Enthusiast
Enthusiast
Posts: 796
Joined: Tue May 20, 2008 2:12 am
Location: Cologne, Germany
Contact:

[4.20 Mac] ImageButton, 2nd Image for pressed-state

Post 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?
Regards,
JamiroKwai
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

I have a suggestion: if you want a button, use a button, not an image gadget.
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Well, I guess he want's a customized button ...
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
jamirokwai
Enthusiast
Enthusiast
Posts: 796
Joined: Tue May 20, 2008 2:12 am
Location: Cologne, Germany
Contact:

[4.20 Mac] ImageButton, 2nd Image for pressed-state

Post 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.
Regards,
JamiroKwai
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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?
jamirokwai
Enthusiast
Enthusiast
Posts: 796
Joined: Tue May 20, 2008 2:12 am
Location: Cologne, Germany
Contact:

Not quite, but almost

Post 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...
Regards,
JamiroKwai
Post Reply