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

Just starting out? Need help? Post your questions and find answers here.
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

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

Post 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
Last edited by SkyManager on Thu Apr 18, 2019 9:44 am, edited 1 time in total.
User avatar
TI-994A
Addict
Addict
Posts: 2752
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: how to capture the canvas gadget Lost Focus event

Post 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
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
SkyManager
Enthusiast
Enthusiast
Posts: 339
Joined: Tue Jan 30, 2007 5:47 am
Location: Hong Kong

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

Post by SkyManager »

thanks
Post Reply