Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capturing user input from Flex TextInput control: which event to use?

Should I use the change or textInput event to capture user input on a TextInput control? Why?

like image 426
Niko Nyman Avatar asked Nov 12 '08 10:11

Niko Nyman


1 Answers

textInput is dispatched only when the user has input text into the control. change, on the other hand, is dispatched on every change committed by the user. So for example, if the user deletes a part of the text, only the change event is dispatched.

Neither of these is dispatched when the text is modified via code:

flash.events.TextEvent.TEXT_INPUT:

"Dispatched when the user types, deletes, or pastes text into the control."

(ignore the word "delete" there -- I just tried it and this event is not dispatched when text is deleted by the user)

flash.events.Event.CHANGE:

"Dispatched when text in the TextInput control changes through user input. This event does not occur if you use data binding or ActionScript code to change the text."

You can also use the valueCommit event, which is dispatched when the user "commits" the changes (usually by moving the focus away from the text field), but remember that this event is also dispatched when the field value is changed programmatically.

like image 91
hasseg Avatar answered Oct 19 '22 20:10

hasseg