Is there a way to capture an event for when user clicks the clear button (the X at the end of the box). Keypress perhaps?
Thanks, Art
Clear button in EditField
Re: Clear button in EditField
Art,
the Changed Event is fired twice when the Clear Button is pressed.
Both times, the value is blank
I can not think of why you need to know if it is clicked, it would be good to know the reason.
some sample code for a password edit with visibility is below (perhaps this is why you *think* you need to know if the Clear button is clicked.)
the Changed Event is fired twice when the Clear Button is pressed.
Both times, the value is blank
Code: Select all
define_com class(#prim_nmbr) name(#ClearBtnClickCounter)
Evtroutine Handling(#Edit.Changed)
If (#Edit.Value = '')
#ClearBtnClickCounter += 1
else
#ClearBtnClickCounter := 0
endif
if (#ClearBtnClickCount = 2)
#ClearBtnClickCounter := 0
* Do whatever you wanted to do when the Clear Button was clicked...
endif
* Do whatever else you wanted to do when the edit was changed...
Endroutine
some sample code for a password edit with visibility is below (perhaps this is why you *think* you need to know if the Clear button is clicked.)
Code: Select all
Define_Com Class(#PRIM_MD.Edit) Name(#pEdit) Caption('Edit Password Field') Displayposition(2) Left(112) Parent(#COM_OWNER) Tabposition(2) Top(84) Width(976) Clearbutton(True) Prompticoncolor(158:158:158) Passwordchar('*')
Evtroutine Handling(#pEdit.Changed)
#COM_SELF.HandleEditChanged( #pEdit.Value )
Endroutine
Evtroutine Handling(#pEdit.Prompting)
#COM_SELF.SetPromptIcon( (#pEdit.PromptIcon = 'visibility') )
Endroutine
Mthroutine Name(HandleEditChanged)
Define_Map For(*INPUT) Class(#PRIM_ALPH) Name(#EditValue)
If (#pEdit.Value = '')
#pEdit.PromptIcon := ''
#pEdit.PasswordChar := '*'
Return
Endif
* Ensure visibility change icon is shown - but dont change it...
If (#pEdit.PromptIcon <> '')
Return
Endif
If (#pEdit.PasswordChar = '*')
#pEdit.PromptIcon := 'visibility'
Else
#pEdit.PromptIcon := 'visibility_off'
Endif
Endroutine
Mthroutine Name(SetPromptIcon)
Define_Map For(*INPUT) Class(#PRIM_BOLN) Name(#Visible) Mandatory(True)
If (#Visible)
#pEdit.PromptIcon := 'visibility_off'
#pEdit.PasswordChar := ''
Else
#pEdit.PromptIcon := 'visibility'
#pEdit.PasswordChar := '*'
Endif
Endroutine
Re: Clear button in EditField
When the user clicks the clear button i have to reset some other inputs, buttons, etc
I’ll try the clear counter thing. Thanks
I’ll try the clear counter thing. Thanks
Art Tostaine