It is currently Thu Dec 13, 2018 3:29 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: CanvasGadget eventtypes
PostPosted: Sat Sep 22, 2018 6:58 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Nov 25, 2013 6:41 am
Posts: 707
Two errors
1) if the mouse button is pressed beyond the canvas, and the cursor enters the canvas, the event "mouse enter" does not occurs.
2) if the mouse button is pressed inside the canvas, and the cursor leaves the canvas, the event "muse leave" occurs.

Code:
Procedure ButtonHandler()
  Select EventType()
    Case #PB_EventType_MouseEnter
      Debug "MouseEnter"
     
    Case #PB_EventType_MouseLeave
      Debug "MouseLeave"
     
    Case #PB_EventType_LeftButtonUp
      Debug "LeftButtonUp"
     
    Case #PB_EventType_LeftClick
      Debug "LeftClick"
     
     
  EndSelect
EndProcedure

OpenWindow(0, 100, 100, 200, 90, "Mouse events bug", #PB_Window_SystemMenu)

CanvasGadget(0, 10, 10, 180, 30)
BindGadgetEvent(0, @ButtonHandler())

Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow


PureBasic 562 mac os high sierra


Last edited by mestnyi on Sat Sep 22, 2018 11:31 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget eventtypes
PostPosted: Sat Sep 22, 2018 10:12 am 
Offline
Addict
Addict
User avatar

Joined: Tue Oct 09, 2007 2:15 am
Posts: 1002
Its the same on Windows. All Gadgets (also in Programs, they not made with PB) have this behaviour....
I think, it's not a bug...

_________________
PureBasic 5.46 LTS / 5.62 (Windows x86/x64) | Windows10 Pro x64 | Z370 Extreme4 | i7 8770k | 32GB RAM | iChill GeForce GTX 980 X4 Ultra | HAF XF Evo​​
English is not my native language... (I often use DeepL to translate my texts.)


Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget eventtypes
PostPosted: Sat Sep 22, 2018 11:40 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Nov 25, 2013 6:41 am
Posts: 707
Quote:
Its the same on Windows
In the sense of?
For example. Do not the "mouse leave" event occur in the windows after the "left up" event?


Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget eventtypes
PostPosted: Sat Sep 22, 2018 7:54 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Oct 09, 2007 2:15 am
Posts: 1002
If you click on a canvas and hold the left button down, move the mouse out of the canvas and release the button.
Then the events mouse_leave and left_up will be fired immediatly.

_________________
PureBasic 5.46 LTS / 5.62 (Windows x86/x64) | Windows10 Pro x64 | Z370 Extreme4 | i7 8770k | 32GB RAM | iChill GeForce GTX 980 X4 Ultra | HAF XF Evo​​
English is not my native language... (I often use DeepL to translate my texts.)


Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget eventtypes
PostPosted: Sun Sep 23, 2018 4:25 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Nov 25, 2013 6:41 am
Posts: 707
Bisonte wrote:
If you click on a canvas and hold the left button down, move the mouse out of the canvas and release the button.
Then the events mouse_leave and left_up will be fired immediatly.

The first question is, in what sequence is this happening?
The second question is the same whether on mac os and windows you have?
On my Windows with the beginning there is an event "leftup" and only then event "leave". And it is right.
But on my mac os with the beginning there is an event "leave" and only then the event "leftup". And this is not right.


Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget eventtypes
PostPosted: Fri Sep 28, 2018 3:43 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Nov 25, 2013 6:41 am
Posts: 707
one more error in mac os, the left button is pressed, then we start moving the mouse, then release the button there is no "click" event,


Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget eventtypes
PostPosted: Fri Sep 28, 2018 4:52 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1476
Location: Germany
mestnyi wrote:
one more error in mac os, the left button is pressed, then we start moving the mouse, then release the button there is no "click" event,

Actually it is an error under Windows and Linux that an Event MouseClick comes after a movement of the mouse...

Workaround
Code:
Procedure ButtonHandler()
  Select EventType()
    Case #PB_EventType_MouseEnter
      Debug "MouseEnter"
     
    Case #PB_EventType_MouseLeave
      Debug "MouseLeave"
     
    Case #PB_EventType_LeftButtonDown
      Debug "LeftButtonDown"
     
    Case #PB_EventType_LeftButtonUp
      Debug "LeftButtonUp"
      CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
        PostEvent(#PB_Event_Gadget, EventWindow(), EventGadget(), #PB_EventType_LeftClick)
      CompilerEndIf
     
    Case #PB_EventType_LeftClick
      Debug "LeftClick"
     
     
  EndSelect
EndProcedure


P.S. Show CheckCanvasMouse http://www.purebasic.fr/english/viewtop ... 12&t=66856

_________________
My Projects OOP-BaseClass / OOP-BaseClassDispatch / Event-Designer /
PB v3.30 / v5.60 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget eventtypes
PostPosted: Fri Sep 28, 2018 7:36 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Nov 25, 2013 6:41 am
Posts: 707
mk-soft wrote:
Actually it is an error under Windows and Linux that an Event MouseClick comes after a movement of the mouse...

I do not agree that it is more correct.
In fact, the "Click" should occur when the mouse button is released on the same control on which it was clicked after the event "Up".

Quote:
Workaround

Thank you, I did, but as I said, if you go beyond the gadget, there should not be a click event. Here, the problems associated with the first two errors on the first post begin.


Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget eventtypes
PostPosted: Sat Sep 29, 2018 9:48 am 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1476
Location: Germany
I have tested with standard buttons and you are right with the event click.

_________________
My Projects OOP-BaseClass / OOP-BaseClassDispatch / Event-Designer /
PB v3.30 / v5.60 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget eventtypes
PostPosted: Sun Oct 07, 2018 8:08 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Nov 25, 2013 6:41 am
Posts: 707
Another mistake is if you often click on the canvas, the click event is lost. :cry:


Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget eventtypes
PostPosted: Tue Oct 09, 2018 12:38 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Nov 25, 2013 6:41 am
Posts: 707
This time another mistake with Left Down
LeftDown event shoots faster than focus. :oops:
Code:
Procedure ButtonHandler()
  Select EventType()
    Case #PB_EventType_LeftButtonDown
      Debug "LeftButtonDown "+ GetActiveGadget()
     
    Case #PB_EventType_LostFocus
      Debug "LostFocus "+ GetActiveGadget()
     
    Case #PB_EventType_Focus
      Debug "Focus "+ GetActiveGadget()
           
  EndSelect
EndProcedure

OpenWindow(0, 100, 100, 200, 90, "Mouse events bug", #PB_Window_SystemMenu)

CanvasGadget(1, 10, 10, 180, 30, #PB_Canvas_Keyboard)
CanvasGadget(2, 10, 50, 180, 30, #PB_Canvas_Keyboard)

If StartDrawing(CanvasOutput(1))
  DrawText(85, 10, "1", 0,$FFFFFF)
  StopDrawing()
EndIf

If StartDrawing(CanvasOutput(2))
  DrawText(85, 10, "2", 0,$FFFFFF)
  StopDrawing()
EndIf

BindGadgetEvent(1, @ButtonHandler())
BindGadgetEvent(2, @ButtonHandler())

Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow


Top
 Profile  
Reply with quote  
 Post subject: Re: CanvasGadget eventtypes
PostPosted: Thu Oct 11, 2018 7:49 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Nov 25, 2013 6:41 am
Posts: 707
The following code corrects all errors except one.
That is, if you click on one gadget and move the cursor to another gadget and release after all the events of the first gadget, there should have been an input event for the second gadget.
Code:
Procedure Events(EventType.i)
  Protected EventGadget.i = EventGadget()
 
  Select EventType
     
    Case #PB_EventType_Focus          : Debug "Focus eg "+ EventGadget +" ag "+ GetActiveGadget()
    Case #PB_EventType_LostFocus      : Debug "LostFocus eg "+ EventGadget +" ag "+ GetActiveGadget()
    Case #PB_EventType_MouseEnter     : Debug "MouseEnter eg "+ EventGadget +" ag "+ GetActiveGadget()
    Case #PB_EventType_MouseLeave     : Debug "MouseLeave eg "+ EventGadget +" ag "+ GetActiveGadget()
    Case #PB_EventType_LeftButtonDown : Debug "LeftButtonDown eg "+ EventGadget +" ag "+ GetActiveGadget()
    Case #PB_EventType_LeftButtonUp   : Debug "LeftButtonUp eg "+ EventGadget +" ag "+ GetActiveGadget()
    Case #PB_EventType_LeftClick      : Debug "LeftClick eg "+ EventGadget +" ag "+ GetActiveGadget()
     
  EndSelect
EndProcedure

Procedure ButtonHandler()
  Static MouseLeave, LeftClick
  Protected EventType = EventType()
 
  ; Это из за ошибки в мак ос
  CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
    Select EventType
      Case #PB_EventType_MouseLeave
        If GetGadgetAttribute(EventGadget(), #PB_Canvas_Buttons)
          EventType = #PB_EventType_MouseMove
          MouseLeave = 1
        EndIf
       
      Case #PB_EventType_LeftButtonDown
        If GetActiveGadget()<>EventGadget()
          SetActiveGadget(EventGadget())
        EndIf
       
      Case #PB_EventType_LeftButtonUp
        If MouseLeave : MouseLeave = 0
          Events(#PB_EventType_LeftButtonUp)
          EventType = #PB_EventType_MouseLeave
        Else
          Events(#PB_EventType_LeftButtonUp)
          EventType = #PB_EventType_LeftClick
        EndIf
       
      Case #PB_EventType_LeftClick : ProcedureReturn 0
    EndSelect
  CompilerEndIf
 
  Events(EventType)
EndProcedure

OpenWindow(0, 100, 100, 200, 90, "Mouse events bug", #PB_Window_SystemMenu)

CanvasGadget(2, 10, 10, 180, 30, #PB_Canvas_Keyboard)
CanvasGadget(3, 10, 50, 180, 30, #PB_Canvas_Keyboard)

If StartDrawing(CanvasOutput(2))
  DrawText(85, 10, "2", 0,$FFFFFF)
  StopDrawing()
EndIf

If StartDrawing(CanvasOutput(3))
  DrawText(85, 10, "3", 0,$FFFFFF)
  StopDrawing()
EndIf

BindGadgetEvent(2, @ButtonHandler())
BindGadgetEvent(3, @ButtonHandler())

Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


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