Carlos, In your JS implementation I see you already set up a handler that catches "input" events and re-casts them as "change" events. This seems like a perfectly acceptable solution to this issue and much more clean and intuitive than trying to get the AS side to emit "input" instead of change, and have your users work with that 'unfamiliar' event.
I've changed the visibility of the 'inputChangeHandler' to private, as this method shouldn't be overridden, and added a call to 'stopPropagation' for the original event (as Alex suggested), so it doesn't interfere or confuse things later in the chain. Nice work! EdB On Wed, Mar 5, 2014 at 6:19 PM, Carlos Rovira <carlosrov...@apache.org>wrote: > Hi, > > I'm trying to deal with events in JS and I'm finding some troubles. Maybe > you guys more experienced with google closure could help me to find the > way. > > In old Flex SDK, TextInput change event is used to signal changes in text > as user introduces. In JS input text that event is 'input', while 'change' > is called when the text is different and the user press ENTER key or > changes focus. > > If we make the following declaration in a MXML View: > > <basic:TextInput id="myTextInput" > width="300" > change="doSomething()"/> > > This generate the following JS code in get_MXMLDescriptor: > > ... > [org.apache.flex.html.staticControls.TextInput, 2, 'id', true, > 'myTextInput', 'width', true, 300, 0, 1, 'change', this.$EH0, null, > ... > > This makes the TextInput work as expected in SWF (doSomething runs on each > character introduced on TextInput) > > But In JS, without implement anything yet in TextInput.js about input text > handling events, the generated code makes doSomething method runs when user > press ENTER or focus out if text was changed. I tried to implement CHANGE > event with no luck due to the listener generated behind the scenes that > match the same name as native textinput change event. > > Note that If I rename 'change' to 'input' in all places, including > TextInput.as metadata event declaration it works ok, since event match the > input js event. It looks like this: > > <basic:TextInput id="myTextInput" > width="300" > input="doSomething()"/> > > What could we do here? Should we patch MXMLDataInterpreter class to deal > with this particularities (maybe translate 'change' to 'input' behind the > scenes to maintain 'change in AS side)? change from traditional Flex events > to something more JS (so using 'input' instead of 'change'? > > If you find this kind of problems before, maybe you already has some > strategy or framework design rule to follow. > > Thanks > > Carlos > > > -- > Carlos Rovira > http://about.me/carlosrovira > -- Ix Multimedia Software Jan Luykenstraat 27 3521 VB Utrecht T. 06-51952295 I. www.ixsoftware.nl