Page 1 of 1

canvas focus/lostfocus events

Posted: Tue Jan 04, 2022 11:24 pm
by mestnyi

Code: Select all

Procedure Open( ID, flag=0 )
   Static X,Y
   OpenWindow( ID, 300+X,150+Y,170,170,"window_"+Str(ID), #PB_Window_SystemMenu|flag)
   CanvasGadget( ID, 10,10,150,150, #PB_Canvas_Keyboard )
   SetActiveGadget( ID )
   X + 100
   Y + 100
EndProcedure


Open(1, #PB_Window_NoActivate)
Open(2, #PB_Window_NoActivate)
;Open(3, #PB_Window_NoActivate)

Define gadget, down
Repeat
   event = WaitWindowEvent(1)
   
   Select event
      Case #PB_Event_ActivateWindow
         Debug "["+EventWindow( )+"] active"
         
      Case #PB_Event_DeactivateWindow
         Debug " --- "
         Debug "["+EventWindow( )+"] deactive"
         
      Case #PB_Event_Gadget
         Select EventType()
            Case #PB_EventType_Focus
               Debug "["+EventGadget( )+"] focus"
               
            Case #PB_EventType_LostFocus
               Debug "["+EventGadget( )+"] lostfocus"
               
            Case #PB_EventType_LeftButtonDown
               Debug "["+EventGadget( )+"] down"
               
            Case #PB_EventType_LeftButtonUp
               Debug "["+EventGadget( )+"] up"
               
         EndSelect
         
   EndSelect
   
Until event = #PB_Event_CloseWindow

Re: Fixed canvas events

Posted: Wed Jan 05, 2022 4:13 pm
by jacdelad
GetDlgCtrlID_ causes problems on x64 systems an PB 6.0 Alpha 5, however, mk-soft pointed out that "GetProp_(Handle, "pb_id")" works as intended (I use it since then without problems. Just to mention, don't know if it will be relevant in the future.
https://www.purebasic.fr/english/viewto ... 62#p577962

Re: Fixed canvas focus/lostfocus events

Posted: Sun Feb 13, 2022 5:13 pm
by mestnyi
jacdelad wrote: Wed Jan 05, 2022 4:13 pm GetDlgCtrlID_ causes problems on x64 systems an PB 6.0 Alpha 5, however, mk-soft pointed out that "GetProp_(Handle, "pb_id")" works as intended (I use it since then without problems. Just to mention, don't know if it will be relevant in the future.
viewtopic.php?p=577962#p577962
Thank you, I re-uploaded the code, thank you, it turned out as I wanted.

Re: Fixed canvas events

Posted: Mon Feb 14, 2022 4:18 am
by Rinzwind
jacdelad wrote: Wed Jan 05, 2022 4:13 pm GetDlgCtrlID_ causes problems on x64 systems an PB 6.0 Alpha 5, however, mk-soft pointed out that "GetProp_(Handle, "pb_id")" works as intended (I use it since then without problems. Just to mention, don't know if it will be relevant in the future.
https://www.purebasic.fr/english/viewto ... 62#p577962
Apparently fixed in beta 4? Can't reproduce.

Re: canvas focus/lostfocus events

Posted: Mon Sep 16, 2024 8:56 pm
by mestnyi
viewtopic.php?p=579118#p579118
When you click on the gadget in the first window

Code: Select all

 ; tested on the windows
[1] active
[1] focus
 --- 
[1] deactive
[2] active
[1] lostfocus
[2] focus
 --- 
[2] deactive
[2] lostfocus
[1] focus
[1] active
[1] lostfocus
[1] focus
[1] down
[1] up
Isn't this a mistake, shouldn't there be a different sequence of events?