Need to toggle an image button or toolbar button
Need to toggle an image button or toolbar button
I have some animation controls that I need to be able to toggle. Image buttons don't appear to work with SetGadgetState, and toolbar buttons can't be toggled. I tried "SendMessage toolbar,$411,button,6" with no effect.
Please help! Thanks.
Please help! Thanks.
Hello halo,
Does this not work for you ?
Result = ButtonGadget(#Gadget, x, y, Width, Height, Text$ [, Flags])
Description
Create a button gadget in the current GadgetList. If #PB_Any is used as '#Gadget' parameter, the new gadget identifier will be returned as 'Result'. #Gadget will be the number returned by EventGadgetID() command.
'Flags' are always optional and can be composed of one or several (using the bitwise OR operator '|') of the following constants:
#PB_Button_Right : Aligns the button text at the right.
#PB_Button_Left : Aligns the button text at the left.
#PB_Button_Default : Makes the button look as if it is the default button in the window.
#PB_Button_MultiLine : If the text is too long, it will be displayed on several lines.
#PB_Button_Toggle : Creates a toggle button: one click pushes it, another will release it.
Rgrds
Does this not work for you ?
Result = ButtonGadget(#Gadget, x, y, Width, Height, Text$ [, Flags])
Description
Create a button gadget in the current GadgetList. If #PB_Any is used as '#Gadget' parameter, the new gadget identifier will be returned as 'Result'. #Gadget will be the number returned by EventGadgetID() command.
'Flags' are always optional and can be composed of one or several (using the bitwise OR operator '|') of the following constants:
#PB_Button_Right : Aligns the button text at the right.
#PB_Button_Left : Aligns the button text at the left.
#PB_Button_Default : Makes the button look as if it is the default button in the window.
#PB_Button_MultiLine : If the text is too long, it will be displayed on several lines.
#PB_Button_Toggle : Creates a toggle button: one click pushes it, another will release it.
Rgrds
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
Why not try danilos PureTools. In that package you have ToolBar Pro (among other great things). Here is a little plug from the help file:
The library can do much more than that. But it also has what you need. To download it, search for posts by danilo and use the link in his tag. Or visit purearea.netSome features of this Toolbar (TBpro) are different button styles like Push-, Check-, Dropdown- or Text-Buttons, Tooltips for all buttons, Text under or on the right side of the buttons and much more.
PushButton:
#TBpro_PushButton = This is a Button that toggles its
state when you press it.
One click to ´mark´ it, another
click to ´unmark´ it.
search the forum, i posted a toggle toolbar button some time ago
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
Here is a simple two state gadget button tip that you can adapt (just with a better drawing for rendering a 3D effect when the button is pushed or released) :
Code: Select all
#Button_1 = 1
#Button_2 = 2
If OpenWindow(0,0,0,120,100,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"ButtonImage")
ImageID1 = CreateImage(1, 32, 32)
StartDrawing(ImageOutput())
Box(0, 0, 32, 32, #Blue)
StopDrawing()
ImageID2 = CreateImage(2, 32, 32)
StartDrawing(ImageOutput())
Box(0, 0, 32, 32, #Green)
StopDrawing()
If CreateGadgetList(WindowID(0))
; A two state button
ButtonImageGadget(1, 10, 10, 32, 32, ImageID1)
ButtonImageGadget(2, 10, 10, 32, 32, ImageID2)
HideGadget(1, 0)
HideGadget(2, 1)
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = #TRUE
Case #PB_Event_Gadget
Select EventGadgetID()
Case 1
HideGadget(1, 1)
HideGadget(2, 0)
Case 2
HideGadget(1, 0)
HideGadget(2, 1)
EndSelect
EndSelect
Until Quit
EndIf
End
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
i did post the source some time ago as well, and if you looked carefully, at the bottom of the first page is a link...
http://www.xs4all.nl/~bluez/datatalk/pb ... _guide.zip
http://www.xs4all.nl/~bluez/datatalk/pb ... _guide.zip
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
ooops, was still an older sample file... the include was updated, the sample not... :roll:
... although i must say with a bit of effort you could have spotted it...
the sample still used x_toolbar_whatever while in the include file those were renamed to x_pbtoolbar_whatever...
... although i must say with a bit of effort you could have spotted it...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )


