canvas events

Share your advanced PureBasic knowledge/code with the community.
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

canvas events

Post by mestnyi »

Code: Select all

Procedure Open( id, flag=0 )
   Static x,y
   OpenWindow( id, x,y,200,200,"window_"+Str(id), #PB_Window_SystemMenu|flag)
   CanvasGadget( id, 40,40,200-80,55, #PB_Canvas_Keyboard | #PB_Canvas_Container) : CloseGadgetList()
   CanvasGadget( 10+id, 40,110,200-80,55, #PB_Canvas_Keyboard)
   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 "active - "+ EventWindow() 
         
      Case #PB_Event_DeactivateWindow
         Debug "deactive - "+ EventWindow()
         
      Case #PB_Event_Gadget
         Select EventType()
            Case #PB_EventType_Focus
               Debug "focus - "+EventGadget()
               
            Case #PB_EventType_LostFocus
               Debug "lostfocus - "+EventGadget()
               
            Case #PB_EventType_LeftButtonDown
               Debug "down - "+EventGadget()
               
            Case #PB_EventType_LeftButtonUp
               Debug "up - "+EventGadget()
               
            Case #PB_EventType_LeftClick
               Debug "click - "+EventGadget()
               
         EndSelect
         
   EndSelect
   
Until event = #PB_Event_CloseWindow
Last edited by mestnyi on Mon Sep 16, 2024 8:37 pm, edited 9 times in total.
User avatar
jacdelad
Addict
Addict
Posts: 2009
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Fixed canvas events

Post 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
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: Fixed canvas events

Post 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.
https://www.purebasic.fr/english/viewto ... 62#p577962
Thank you, I re-uploaded the code, thank you, it turned out as I wanted.
Rinzwind
Enthusiast
Enthusiast
Posts: 690
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

Re: Fixed canvas events

Post 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.
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: canvas events

Post by mestnyi »

viewtopic.php?p=579118#p579118
When you click on the first gadget in the first window, then on the first gadget in the second window and again on the first gadget in the first window

Code: Select all

; first window
active - 1
focus - 1
down - 1
up - 1
click - 1
; second window
deactive - 1
active - 2
lostfocus - 1
focus - 2
down - 2
up - 2
click - 2
; first window
deactive - 2
lostfocus - 2
focus - 1
active - 1
lostfocus - 1
focus - 1
down - 1
up - 1
click - 1
Isn't this a mistake, shouldn't there be a different sequence of events?
Post Reply