Page 1 of 1
Need to toggle an image button or toolbar button
Posted: Sat May 15, 2004 8:49 pm
by halo
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.
Posted: Sat May 15, 2004 9:12 pm
by fweil
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
Posted: Sat May 15, 2004 10:59 pm
by halo
No, I need an image on the button, and the buttonimagegadget is not able to be toggled.
Posted: Sun May 16, 2004 12:44 am
by thefool
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:
Some 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.
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.net
Posted: Sun May 16, 2004 12:57 am
by halo
Thanks I will try this.
Posted: Sun May 16, 2004 1:29 am
by halo
It doesn't work. I give up.
It took me twenty minutes to write a routine that automatically assigns vertex weighting, and three hours to try to figure out how to make a stupid little button stay pressed.
Posted: Sun May 16, 2004 8:48 am
by blueznl
search the forum, i posted a toggle toolbar button some time ago
Posted: Sun May 16, 2004 9:41 am
by fweil
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
Posted: Sun May 16, 2004 10:00 am
by blueznl
Posted: Sun May 16, 2004 5:14 pm
by halo
I know, I found that post, but it needed some xlib file or something. I followed the link to a page that was a lot of primers, and it was totally impossible to find anything.
Posted: Sun May 16, 2004 5:54 pm
by blueznl
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
Posted: Sun May 16, 2004 7:27 pm
by halo
Oh cool, thanks.
Posted: Sun May 16, 2004 7:43 pm
by halo
Well, I run toolbar_1.pb, and get this error:
Line 12: Error in the included file 'x_lib.pb'
Line 761: A Structure name is expected inside SizeOf()
Posted: Sun May 16, 2004 9:59 pm
by blueznl
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...