Page 1 of 1

[Solved] how to capture the canvas gadget Lost Focus event

Posted: Thu Apr 18, 2019 8:07 am
by SkyManager
Could anybody help?
I cannot capture the canvas gadget Lost Focus event!

Code: Select all

OpenWindow(0, 500, 0, 50, 25, "test")
CanvasGadget(1, 0, 0, 25, 25)

WinQuit = #False
Repeat
  Select WaitWindowEvent()
     Case #PB_Event_Gadget
       If EventGadget() = 1
         If EventType() = #PB_EventType_LostFocus
           Debug "Lost Focus" ; <---- This can never be captured!!!
         Else
           Debug "Got Focus" ; <---- This is captured OK
         EndIf
       EndIf
     Case #PB_Event_CloseWindow
       WinQuit = #True
  EndSelect
Until WinQuit
End

Re: how to capture the canvas gadget Lost Focus event

Posted: Thu Apr 18, 2019 8:21 am
by TI-994A
SkyManager wrote:I cannot capture the canvas gadget Lost Focus event!
Firstly, the canvas gadget must include the #PB_Canvas_Keyboard directive. Then, it can only lose focus to another gadget that can receive focus:

Code: Select all

wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(0, 500, 0, 250, 250, "test", wFlags)
CanvasGadget(1, 0, 0, 250, 150, #PB_Canvas_Keyboard)
StringGadget(2, 10, 200, 230, 30, "click me...")
SetActiveGadget(1)

WinQuit = #False
Repeat
  Select WaitWindowEvent()
     Case #PB_Event_Gadget
       If EventGadget() = 1
         If EventType() = #PB_EventType_LostFocus
           Debug "Lost Focus"
         ElseIf EventType() = #PB_EventType_Focus
           Debug "Got Focus"
         EndIf
       EndIf
     Case #PB_Event_CloseWindow
       WinQuit = #True
  EndSelect
Until WinQuit
End

[Solved] Re: how to capture the canvas gadget Lost Focus eve

Posted: Thu Apr 18, 2019 9:43 am
by SkyManager
thanks