canvas lost focus

Just starting out? Need help? Post your questions and find answers here.
mestnyi
Addict
Addict
Posts: 1102
Joined: Mon Nov 25, 2013 6:41 am

canvas lost focus

Post by mestnyi »

in mac os is this bug?

Code: Select all

Procedure lostfocus( )
  Debug "lostfocus"
  SetActiveGadget( - 1 )
EndProcedure

OpenWindow(1, 0, 0, 320, 400, "bug", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(1, 10, 10, 300, 300, #PB_Canvas_DrawFocus )
BindGadgetEvent(1, @lostfocus( ), #PB_EventType_LostFocus)

SetActiveGadget(1)
SetActiveGadget( - 1 )

Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: canvas lost focus

Post by infratec »

Don't you need

Code: Select all

#PB_Canvas_Keyboard
for keyboard stuff?
BarryG
Addict
Addict
Posts: 4218
Joined: Thu Apr 18, 2019 8:17 am

Re: canvas lost focus

Post by BarryG »

What if he's changing the focus to another gadget by clicking with the mouse?
mestnyi
Addict
Addict
Posts: 1102
Joined: Mon Nov 25, 2013 6:41 am

Re: canvas lost focus

Post by mestnyi »

infratec wrote: Thu Oct 02, 2025 11:46 am Don't you need

Code: Select all

#PB_Canvas_Keyboard
for keyboard stuff?
Maybe it should, but that's not the point.
The point is that in Mac OS, an infinite loop starts, whereas in Windows, there is no such thing.
mestnyi
Addict
Addict
Posts: 1102
Joined: Mon Nov 25, 2013 6:41 am

Re: canvas lost focus

Post by mestnyi »

BarryG wrote: Thu Oct 02, 2025 12:07 pm What if he's changing the focus to another gadget by clicking with the mouse?
My problem is visible immediately after compiling the code.
User avatar
Piero
Addict
Addict
Posts: 1040
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: canvas lost focus

Post by Piero »

seems like SetActiveGadget( -1 ) ALWAYS triggers lost focus

Code: Select all

Procedure lostfocus( )
  Debug "lostfocus"
  ;SetActiveGadget( -1 )
EndProcedure
Post Reply