Hi Erik,

thanks, I have a version locally without the need of InputHandler goog
class to remove that dependency, but although I'm with you that this
solution should be the right from a design perspective it's not working for
me. The method is getting called due to MXMLDataInterpreter setup internals
(so it seems to be out of the control and scope of developer) and not due
to the CHANGE event that TextInput.js propagates (if I remove this
listener/event the change *native* event is operating and is what I think
we should remove in some way, maybe patching the MXMLDataInterpreter to
avoid making a listener of text input to change event).

Maybe with your changes now you get it working (could you confirm)? that
would be great since after thinking in my proposal and Alex comments I
would prefer to maintain Flex API as possible and not going to map JS
'input' event. FlexJS users would expect CHANGE to work as they do in
traditional Flex.

I'm this morning out, but I'd like to get it back to this issue this night.

Thanks Erik for take the time to see this since you're more experienced
with all this JS stuff and it's good to have your validation.

Best,

Carlos





2014-03-06 9:29 GMT+01:00 Erik de Bruin <e...@ixsoftware.nl>:

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



-- 
Carlos Rovira
Director de TecnologĂ­a
M: +34 607 22 60 05
F:  +34 912 94 80 80
http://www.codeoscopic.com
http://www.directwriter.es
http://www.avant2.es

Reply via email to