Page 1 of 1

Stringgadget generate two events. Why?

Posted: Thu Jan 28, 2021 9:17 pm
by Johanson

Code: Select all

OpenWindow(#PB_Any, 100,100, 250,80, "")
StringGadget(1, 100,20, 50,25, "abc")
Repeat
  Select WindowEvent()
    Case #PB_Event_Gadget
      If EventGadget()=1
        Debug "gadget 1"
      EndIf
    Case #PB_Event_CloseWindow
      Break
  EndSelect
Until false

Re: Stringgadget generate two events. Why?

Posted: Thu Jan 28, 2021 9:21 pm
by Bisonte
Different Eventtypes !

Code: Select all

 OpenWindow(#PB_Any, 100,100, 250,80, "")
StringGadget(1, 100,20, 50,25, "abc")
Repeat
  Select WindowEvent()
    Case #PB_Event_Gadget
      If EventGadget()=1
        Debug "gadget 1"
        Debug EventType()
      EndIf
    Case #PB_Event_CloseWindow
      Break
  EndSelect
Until false

Re: Stringgadget generate two events. Why?

Posted: Thu Jan 28, 2021 9:30 pm
by Johanson
Fact
14000 and 256

Thanks

Re: Stringgadget generate two events. Why?

Posted: Thu Jan 28, 2021 9:44 pm
by Johanson
EvenType()=14000 means "Get the focus"

and .. EvenType()=256 ???

Are there any other besides:
0 Left mouse button click
1 Right mouse button click
2 Left mouse button double click
3 Right mouse button double click
768 Content change
14000 Get the focus
14001 Lose the focus
14002 EventType_DragStart ?

Re: Stringgadget generate two events. Why?

Posted: Thu Jan 28, 2021 11:39 pm
by mk-soft
Check always the valid event types. See gadget helps ...

Code: Select all

If OpenWindow(0, 100,100, 250,80, "")
  StringGadget(1, 100,20, 50,25, "abc")
  Repeat
    Select WindowEvent()
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1
            Debug "gadget 1"
            Select EventType()
              Case #PB_EventType_Change    : Debug "The text has been modified by the user."
              Case #PB_EventType_Focus     : Debug "The StringGadget got the focus."
              Case #PB_EventType_LostFocus : Debug "The StringGadget lost the focus."
                
            EndSelect
            
        EndSelect
        
      Case #PB_Event_CloseWindow
        Break
        
    EndSelect
    
  ForEver
EndIf

Re: Stringgadget generate two events. Why?

Posted: Sun May 09, 2021 12:27 pm
by Lima
If it is necessary to display a message to the user, it enters an infinite cycle
" got the focus", " lost the focus".
IIs this correct?
Or where is the error?

Code: Select all

If OpenWindow(0, 100,100, 250,200, "")
  StringGadget(1, 100,20, 50,25, "abc")
    StringGadget(2, 100,50, 50,25, "xyz")
  Repeat
    Select WindowEvent()
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1
            Debug "gadget 1"
            Select EventType()
              Case #PB_EventType_Change    : Debug "The text has been modified by the user."
              Case #PB_EventType_Focus    
                Debug "The StringGadget got the focus."
                   MessageRequester(""," got the focus")
                
              Case #PB_EventType_LostFocus 
                Debug "The StringGadget lost the focus."
                MessageRequester(""," lost the focus")
                
            EndSelect
            
        EndSelect
     
        
      Case #PB_Event_CloseWindow
        Break
        
    EndSelect
    
  ForEver
EndIf

   

Re: Stringgadget generate two events. Why?

Posted: Sun May 09, 2021 1:28 pm
by mk-soft
Of course it is true that the EditGadget loses focus when another window like the MessageRequester is created. Only one object can have focus at a time.