Thanks for the example. Yes, I think the enumerations are better. Incidentally, clicking #GADGET_BtnClickMe only detects the loss of focus. Your message Debug "Click on ClickMe Button" doesn't appear to be executed. I just mention this for the benefit of anyone taking a look at this.Axolotl wrote: Wed Aug 31, 2022 11:26 am Simply written: Never use numbers, always use predefined constants or like here enumerations.
Disadvantage: You have to write more code. In larger applications, however, this will be worthwhile. Especially because there are not so many errors caused by wrong numbers.Code: Select all
Repeat Select WaitWindowEvent() Case #PB_Event_CloseWindow ; deal with the events here or use BindEvent() Break ; exit the main loop Case #PB_Event_Gadget Select EventGadget() Case #GADGET_StrInput Select EventType() Case #PB_EventType_Change :Debug "Change" ; The text has been modified by the user. Case #PB_EventType_Focus :Debug "Focus" ; The StringGadget got the focus. Case #PB_EventType_LostFocus :Debug "LostFocus" ; The StringGadget lost the focus. Case #GADGET_BtnClickMe Debug "Click on ClickMe Button" EndSelect EndSelect EndSelect ForEver EndIf
It works if you move your first EndSelect up by two lines. I guess that's what was intended anyway.
Click in the string box - Focus
Press 1 - Change
Press 2 - Change
Press 3 - Change
Click button - LostFocus