Need to toggle an image button or toolbar button

Everything else that doesn't fall into one of the other PB categories.
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Need to toggle an image button or toolbar button

Post 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.
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post 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
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.
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Post by halo »

No, I need an image on the button, and the buttonimagegadget is not able to be toggled.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post 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
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Post by halo »

Thanks I will try this.
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Post 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.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

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... )
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post 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
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.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

( 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... )
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Post 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.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

Post 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
( 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... )
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Post by halo »

Oh cool, thanks.
halo
Enthusiast
Enthusiast
Posts: 104
Joined: Mon Jan 26, 2004 2:49 am

Post 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()
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

Post 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...
( 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... )
Post Reply