Clear button in EditField
Posted: Tue Aug 04, 2020 11:09 am
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
Thanks, Art
Community Forum for Visual LANSA
https://forum.developer.lansa.com/
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
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