Funny, I see it too in our app, but this works

<?xml version="1.0" encoding="utf-8"?>
<s:Application
           xmlns:fx="http://ns.adobe.com/mxml/2009";
           xmlns:s="library://ns.apache.org/royale/spark"
           creationComplete="init()"
           >
           <fx:Script>
                      <![CDATA[

                                 import components.MyComp;
                                 import mx.collections.ArrayList;

                                 private function init():void
                                 {
                                            var dp:ArrayList = new 
ArrayList(['one', 'two', 'three']);
                                            myList.dataProvider = dp;
                                 }

                                 private function changeHandler():void
                                 {
                                            trace("here i am");
                                 }

                      ]]>
           </fx:Script>
           <s:List id="myList" width="100%" height="100%" 
change="changeHandler()"/>
</s:Application>



From: Greg Dove<mailto:greg.d...@gmail.com>
Sent: Sunday, December 13, 2020 5:40 AM
To: Apache Royale Development<mailto:dev@royale.apache.org>
Subject: What to do for 'change' type events in Event subclasses (emulation)

Events that have 'change' string type do not appear to work as advertised
in SparkRoyale (and perhaps in MX as well, although I am only eyes-on with
Spark at the moment).

Because 'change' is treated specially at the level of ElementWrapper, it
gets swapped for a browser 'change' event.

This seems to be avoidable simply by renaming to event name in the subclass
to avoid the conflict.
e.g. IndexChangeEvent  monkey patch:

public static const CHANGE:String = 'indexChange'; //was 'change'

and also, for example, in DropDownListController:
//added IndexChangeEvent
  var ice:IndexChangeEvent = new IndexChangeEvent(IndexChangeEvent.CHANGE,
false,false,selectionModel.selectedIndex, popUpModel.selectedIndex );
        selectionModel.selectedIndex = popUpModel.selectedIndex;
        //was : dispatch the generic 'change' event
        IEventDispatcher(_strand).dispatchEvent(new Event("change"));
        //also now: dispatch the IndexChangeEveht (monkey patch
IndexChangeEvent.CHANGE)
        IEventDispatcher(_strand).dispatchEvent(ice);

Above is quick and dirty... and seems to work for now where needed. But is
there a way to do this correctly (similar to Keyboard and Mouse
conversions) so that 'change' event names don't need to be renamed?
Obviously it affects mxml event completion also which is normally typed to
the subclass for the 'change' event name, so it is not necessarily
desirable simply to change the const values because then all the mxml that
is based on the original value needs to be changed also.

Does anyone else have an approach that addresses this issue more generally?
Would appreciate any thoughts/insight....

thanks,
Greg

Reply via email to