Getting Toolbar buttons to work..

BlitzPlus Forums/BlitzPlus Programming/Getting Toolbar buttons to work..

Hi

I have recently purchased BlitzPlus and i have been trying out the GUI features and earlier today made a toolbar.

I have set up the toolbar in the following way.


toolbar=CreateToolBar( "toolbar.bmp",0,0,0,0,Main )

SetToolBarTips toolbar,"New,Open,Home,Back,Forward,Calculator,About"

panel=CreatePanel( 0,GadgetHeight(toolbar),ClientWidth(Main),ClientHeight(Main)-GadgetHeight(toolbar),Main )
SetGadgetLayout panel,1,1,1,1


and then to get my buttons to work i have done this...


EvData=EventData()

If EvData=1 Then HtmlViewGo html,"http://www.stevemountain.com"
If EvData=2 .... etc etc


Now this works however the first button on my toolbar does not as that would be EvData = 0 and when i do that, the action is happening all the time without any pressing needed.


Plus if i use my scroll wheel on my mouse it sometimes executes one of the actions which should only be a toolbar button action.


So i am guessing that this is the incorrect way to set up toolbar buttons for actions, so could someone please tell me what the correct way is?


Many thanks

Tails

Make sure EventSource() = toolbar.

Your event loop would look something like this:
Select Waitevent()
Case $401 ; Gadget action
Select EventSource()
Case toolbar
Select EventData
Case 0 ; Button 0
Case 1 ; Button 1
Case 2 ; Button 2
End Select
End Select
End Select