It is currently Fri May 24, 2013 11:09 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Twice the events
PostPosted: Sat Sep 22, 2012 10:27 pm 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Fri Apr 25, 2003 4:47 pm
Posts: 600
Location: New Zealand
Can anyone advise me why we are getting 2 events every time a tab is clicked?

it might seam logical to only get the 1, since it is only 1 click.

Code:
#WindowWidth  = 390
#WindowHeight = 350

If OpenWindow(0, 100, 200, #WindowWidth, #WindowHeight, "PureBasic - Gadget Demonstration", #PB_Window_MinimizeGadget)
   
  Top = 10
  GadgetHeight = 24

  Frame3DGadget(#PB_Any, 10, Top, 370, 290, "Player...") : Top+20

  StringGadget(0,  20, Top, 200, GadgetHeight, "")
  ButtonGadget(1, 223, Top,  72, GadgetHeight, "Play")
  ButtonGadget(2, 295, Top,  72, GadgetHeight, "Stop")  : Top+35
  DisableGadget(2,1)
 
  GadgetToolTip(1,"Play the current song")
 
  PanelGadget(3, 20, Top, #WindowWidth-50, #WindowHeight-Top-60)
    AddGadgetItem(3, 0, "MP3 PlayList")
      ListViewGadget(4, 6, 10, 230, 148)

      For k=0 To 30
        AddGadgetItem(4, -1, "Music Song n° "+Str(k))
      Next

      ButtonGadget(5,  250, 10, 80, GadgetHeight, "Add")
      ButtonGadget(6,  250, 38, 80, GadgetHeight, "Remove")
      ButtonGadget(7,  250, 66, 80, GadgetHeight, "Select")
      GadgetToolTip(7, "Select the current song")
     
      TrackBarGadget(17, 10, 168, 310, 25, 0, 100)

    AddGadgetItem(3, 1, "Options")
      Top = 10
      CheckBoxGadget(10, 10, Top, 250, GadgetHeight, "Enable low-pass filter") : Top+30
      CheckBoxGadget(11, 10, Top, 250, GadgetHeight, "Enable visual plug-in")  : Top+30
      ComboBoxGadget(12, 10, Top, 250, 21) : Top+30
        AddGadgetItem(12, -1, "FireWorks")
        AddGadgetItem(12, -1, "OpenGL spectrum")
        AddGadgetItem(12, -1, "Bump bass")
      SetGadgetState(12,0)
      DisableGadget(12,1)
     
      OptionGadget(13, 10, Top, 80, GadgetHeight, "640*480") : Top+20
      OptionGadget(14, 10, Top, 80, GadgetHeight, "800*600") : Top+20
      OptionGadget(15, 10, Top, 80, GadgetHeight, "1024*768")
      SetGadgetState(13, 1)
     
      ButtonGadget(16, 150, Top, 80, GadgetHeight, "Info")
  CloseGadgetList()

  TextGadget  (9, 10, #WindowHeight-30, 250, 24, "PureBasic - Gadget demonstration")
  ButtonGadget(8, #WindowWidth-100, #WindowHeight-36, 80, 24, "Quit")

  SetGadgetState(3, 0)

  Repeat
    EventID = WaitWindowEvent()
   
    If EventID = #PB_Event_Gadget
     
      Debug "2 Events Triggered, only 1 panel clicked!"
     
      Select EventGadget()
        Case 0
          If EventType() = #PB_EventType_ReturnKey
            MessageRequester("Info", "Return key pressed", 0)
            SetActiveGadget(0)
          EndIf
         
        Case 1 ; Play
          DisableGadget(2,0)  ; Enable the 'Stop' gadget
          DisableGadget(1,1)  ; Disable the 'Play' Gadget
     
        Case 2 ; Stop
          DisableGadget(1,0)  ; Enable the 'Play' gadget
          DisableGadget(2,1)  ; Disable the 'Stop' Gadget
       
        Case 4
          If EventType() = 2
            SetGadgetText(0, GetGadgetText(4)) ; Get the current item from the ListView..
          EndIf

        Case 5 ; Add
          AddGadgetItem(4, -1, "New Item Added...")

        Case 6 ; Remove
          RemoveGadgetItem(4, GetGadgetState(4)) ; Remove the current element of the ListView

        Case 7 ; Select
          SetGadgetText(0, GetGadgetText(4)) ; Get the current item from the ListView..
 
        Case 8 ; Quit...
          EventID = #PB_Event_CloseWindow

        Case 11 ; Enable PlugIn..
          DisableGadget(12, 1-GetGadgetState(11))
         
        Case 16 ;
          If GetGadgetState(13) : Result$ = GetGadgetText(13) : EndIf
          If GetGadgetState(14) : Result$ = GetGadgetText(14) : EndIf
          If GetGadgetState(15) : Result$ = GetGadgetText(15) : EndIf
         
          MessageRequester("Info", "Selected screen mode: "+Result$, 0)
       
        Case 17
          SetGadgetText(0, Str(GetGadgetState(17)))
         
      EndSelect

    EndIf

  Until EventID = #PB_Event_CloseWindow

EndIf

End


Top
 Profile  
 
 Post subject: Re: Twice the events
PostPosted: Sun Sep 23, 2012 1:15 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Sep 22, 2010 1:17 pm
Posts: 137
Location: United Kingdom
If you look at the EventType() for each event you will see that a left click and a right click event are both generated for each panel click event. You could ignore the extraneous right click by only responding to the #PB_EventType_LeftClick event type.


Top
 Profile  
 
 Post subject: Re: Twice the events
PostPosted: Sun Sep 23, 2012 2:27 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Jun 02, 2003 9:16 am
Posts: 1917
Location: Germany
spikey wrote:
If you look at the EventType() for each event you will see that a left click and a right click event are both generated for each panel click event. You could ignore the extraneous right click by only responding to the #PB_EventType_LeftClick event type.

A left and right click event although I only clicked with one mouse button? If you mean mouse down and up its okay, but the values aren't the same:
Code:
Debug EventType()
says, 0 on down and 1 on up, while
Code:
Debug #PB_EventType_LeftButtonDown
Debug #PB_EventType_LeftButtonUp
says
Quote:
65540
65541

_________________
bye,
Daniel

http://www.bradan.eu/


Top
 Profile  
 
 Post subject: Re: Twice the events
PostPosted: Wed Sep 26, 2012 1:21 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Sep 22, 2010 1:17 pm
Posts: 137
Location: United Kingdom
I never said I understood why it's happening - I just said what was happening and what you could do about it. :D

I guess technically its a bug - but as a panelgadget doesn't generate a right click event (at least not by the WindowEvent command) its not a hugely inconvenient one.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: jack and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye