Page 1 of 1

Stringgadget and lost focus

Posted: Thu Jul 28, 2005 2:51 pm
by pel
Just curious why I get a "lost focus" event for a stringgadget each time I type in a character (although the focus actually stays on the stringgadget). I get the lost focus event using either #PB_EventType_LostFocus or #EN_KILLFOCUS.

As an example, if you take the "Gadget" example program and add a check for lost focus and a debug message under "Case 0" (the stringgadget), you'll see a "lost focus" message pop up in the debug window each time you type a character. :?

Posted: Thu Jul 28, 2005 10:49 pm
by Sub-Routine
Works as expected here. I only see the Lost Focus when tabbing to or clicking another gadget.

I use it in my program to update other gadgets only after the user has finished input to certain gadgets.

PB 393, XP Pro SP2

Rand

Posted: Thu Jul 28, 2005 11:10 pm
by pel
Sorry, I didn't make this clear - I've got a "lost focus" routine in my program and everything works OK -- it's just that the "lost focus" routine gets executed every time a character is entered. It seems to be getting both a "Change" and "Lost focus" event with each character, although the focus isn't actually "lost" -- it stays on the stringgadget until you actually tab or click to another gadget.

Posted: Thu Jul 28, 2005 11:46 pm
by Sub-Routine
Here is how I use it:

Code: Select all

    ElseIf GadgetID = #Final_Drive_Whole_Input
      Gosub Final_Drive
      If EventType() = #PB_EventType_LostFocus
        Gosub GearRatios
        Gosub Speed_Per_Mile
      EndIf
The Final_Drive_Whole_Input is a string gadget which I interpret into a Float value in Final_Drive which updates only one gadget, and updates for every keypress.

After the user moves to another gadget (LostFocus) GearRatios (as many as 35 gadgets) and Speed_Per_Mile (a ListIcon, often containing 200 or more entries) are updated.

I don't understand why it isn't functioning for you.

Rand