#PB_EVENT_Enumerations

Just starting out? Need help? Post your questions and find answers here.
Andrew Lindsay
User
User
Posts: 24
Joined: Mon May 30, 2011 12:17 pm

#PB_EVENT_Enumerations

Post by Andrew Lindsay »

So, I'm trying to find my way through the examples and getting to find the quirks of PureBasic from other compilers etc.

When I look at the example programs, such as the GadgetAdvanced.pb, I see the select case statement as follows....

Code: Select all

        Case 2
          SetGadgetText(4, "Tree Gadget. Item selected: "+Str(GetGadgetState(2)))
          
          If EventType() = 2; 
            MessageRequester("Information", "Doubleclick: item"+Str(GetGadgetState(2))+", Text: "+GetGadgetText(2), 0)
            MessageRequester("Information", Str(#PB_Event_LeftDoubleClick),0)
            
          ElseIf EventType() = 1
            DisplayPopupMenu(0, WindowID(0))
          EndIf
Now, I would love to believe that the EventType() = 2 is a double click, because when I double click on it, I get a message that says, 'Doubleclick'....

But when I change the '2' to #PB_Event_LeftDoubleClick, I don't get any response when I double click.

In debugging I find that the value of #PB_Event_LeftDoubleClick = 18, not 2.

Where do I get the list of what the enumerations should be?

Regards

Andrew
Andrew Lindsay
-----------------------------------------
User avatar
spikey
Enthusiast
Enthusiast
Posts: 750
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: #PB_EVENT_Enumerations

Post by spikey »

Sounds like that example needs an overhaul...

You need to use #PB_EventType_LeftDoubleClick constant.

It's a much better idea to use the constants by name rather than their underlying numeric, it improves the readability and self documentation of the source code and renders it immune to unexpected modifications in later versions which would otherwise cause a bug.

The events and types supported by each gadget are noted in the help page for the gadget.

If you really want to know what all the underlying numeric values are then see this thread:-
http://www.purebasic.fr/english/viewtop ... 1&start=15
Post Reply