Clear button in EditField

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Clear button in EditField

Post by atostaine »

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
Art Tostaine
BrendanB
Posts: 134
Joined: Tue Nov 24, 2015 10:29 am

Re: Clear button in EditField

Post by BrendanB »

Art,

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

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.)

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

atostaine
Posts: 696
Joined: Wed Jan 20, 2016 7:38 am

Re: Clear button in EditField

Post by atostaine »

When the user clicks the clear button i have to reset some other inputs, buttons, etc

I’ll try the clear counter thing. Thanks
Art Tostaine
Post Reply