Page 1 of 1

Control "lost focus" message

Posted: Fri May 04, 2007 4:41 pm
by milan1612
How can I process a "Lost Focus" Event of a StringGadget?
I tried #WM_KILLFOCUS but didn't get it to work.
Has anybody tried that already?

Regards, milan1612

Posted: Fri May 04, 2007 4:52 pm
by Fluid Byte

Code: Select all

OpenWindow(0,0,0,400,300,"untitled",#WS_OVERLAPPEDWINDOW | 1)
CreateGadgetList(WindowID(0))
StringGadget(0,5,5,200,20,"lorem ipsum")
ButtonGadget(1,5,40,100,24,"screw u")

Repeat
	EventID = WaitWindowEvent()
	
	If EventID = #PB_Event_Gadget And EventType() = #PB_EventType_LostFocus
		Debug "HAX0RS ON TEH PC!"
	EndIf
Until EventID = 16
:?:

Posted: Fri May 04, 2007 5:48 pm
by milan1612
Actually I didn't see it :?: :?: :?:
What's going on with me :oops:
Thanks anyway :D

Posted: Fri May 04, 2007 5:56 pm
by Fluid Byte
LOL no problem! Image

Posted: Fri May 04, 2007 6:02 pm
by Num3
My sugar version...

Code: Select all

OpenWindow(0,0,0,400,300,"untitled",#WS_OVERLAPPEDWINDOW | 1)
CreateGadgetList(WindowID(0))
StringGadget(0,5,5,200,20,"lorem ipsum")
ButtonGadget(1,5,40,100,24,"screw u")

Procedure FocusText(gadget.l,focuscolor.l=$E2E3E1,unfocuscolor.l=$FFFFFF)
  If GadgetType(gadget.l)=#PB_GadgetType_String 
    If EventType()=#PB_EventType_Focus 
      SetGadgetColor(gadget,#PB_Gadget_BackColor,focuscolor)
    ElseIf EventType()=#PB_EventType_LostFocus 
      SetGadgetColor(gadget,#PB_Gadget_BackColor,unfocuscolor)
    EndIf
  EndIf
EndProcedure


Repeat
  EventID = WaitWindowEvent()
  EventGadget = EventGadget()
  
  
  If EventID = #PB_Event_Gadget 
    FocusText(EventGadget)
    If EventType() = #PB_EventType_LostFocus
    
    Debug "HAX0RS ON TEH PC!"
  EndIf
  EndIf
Until EventID = 16

Posted: Fri May 04, 2007 6:14 pm
by milan1612
That's quite exactly that what I tried to do :D

Posted: Fri May 04, 2007 6:19 pm
by Num3
milan1612 wrote:That's quite exactly that what I tried to do :D
;)

Code: Select all

Procedure FocusText(gadget.l,focuscolor.l=$E2E3E1,unfocuscolor.l=$FFFFFF)
  If GadgetType(gadget.l)=#PB_GadgetType_String
    If EventType()=#PB_EventType_Focus
      SetGadgetColor(gadget,#PB_Gadget_BackColor,focuscolor)
    ElseIf EventType()=#PB_EventType_LostFocus
      SetGadgetColor(gadget,#PB_Gadget_BackColor,unfocuscolor)
    EndIf
  EndIf
EndProcedure 
That's all ya need then !

Posted: Sat May 05, 2007 4:15 am
by JCV
Thats nice.
Added more fancy on my project. :lol: