It is currently Thu Dec 13, 2018 7:47 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Canvas Button States delayed?
PostPosted: Mon Nov 20, 2017 3:58 pm 
Offline
Addict
Addict

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 869
Location: right here
If i press and hold the left mouse button then i get the left down event, but the button attribute is not set yet. Then keeping the button pressed and moving the mouse to get another event shows the attribute to be set correctly. The same happens with the up event/state, i get the left up and left click events but the button attribute is only updated on later events.

I using Linux, Ubuntu 16.04 and PB 5.61 x64.
Does anyone spot something wrong with my code and what is the result on Windows?
Code:
EnableExplicit

Define ww, wh, win, style
ww=800
wh=600
style | #PB_Window_ScreenCentered
style | #PB_Window_SystemMenu
style | #PB_Window_MinimizeGadget

win = OpenWindow(#PB_Any, 50,100, ww,wh, "", style)
AddKeyboardShortcut(win, #PB_Shortcut_Escape, 10)
Define canvas = CanvasGadget(#PB_Any, 0, 0, ww, wh)

Define event, em, eg, et, quit
Define canvasLeftButtonDown, canvasRightButtonDown

Repeat
 
  ; ...
 
  Repeat
    event = WindowEvent()
    em = EventMenu()
    eg = EventGadget()
    et = EventType()
    Select event
      Case #PB_Event_CloseWindow
        quit = #True
      Case #PB_Event_Menu
        Select em
        Case 10
          quit = #True
        EndSelect
      Case #PB_Event_Gadget
       
        Debug "gadget event"
       
        If et = #PB_EventType_LeftButtonDown
          Debug " left down"
        EndIf
        If et = #PB_EventType_LeftButtonUp
          Debug " left up"
        EndIf
        If et = #PB_EventType_LeftClick
          Debug " left click"
        EndIf
       
        canvasLeftButtonDown  = GetGadgetAttribute(canvas, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton
        Debug " down: " + canvasLeftButtonDown

    EndSelect
  Until Not event
 
  ; ...
 
Until quit


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas Button States delayed?
PostPosted: Mon Nov 20, 2017 4:42 pm 
Offline
Addict
Addict

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 1602
Location: Uttoxeter, UK
@NULL,
I ran your code on Windows 10 x64 with PureBasic 5.61 x64

On holding the left button down I get:

gadget event
left down
down: 1


If I move the mouse, whilst keeping the button down, the above is continually repeated until button up.

_________________
DE AA EB


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas Button States delayed?
PostPosted: Mon Nov 20, 2017 5:31 pm 
Offline
Addict
Addict

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 869
Location: right here
Seems to work ok then. It looks like this on my system:
Code:
gadget event
 left down
 down: 0
gadget event
 down: 1
gadget event
 down: 1
gadget event
 left up
 down: 1
gadget event
 left click
 down: 1
gadget event
 down: 0
gadget event
 down: 0
gadget event
 down: 0


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: Bitblazer, Exabot [Bot] and 19 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