You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flex.apache.org by "Maurice Amsellem (JIRA)" <ji...@apache.org> on 2014/03/13 23:45:44 UTC

[jira] [Comment Edited] (FLEX-34143) Give an event handle.

    [ https://issues.apache.org/jira/browse/FLEX-34143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13934240#comment-13934240 ] 

Maurice Amsellem edited comment on FLEX-34143 at 3/13/14 10:44 PM:
-------------------------------------------------------------------

BTW, there is another mxml tag in the cairngorm observer lib that is called EventListener, which is a binding-based event listener, that will listen to the event at the end of the binding chain.

the implementation is more complex that Observe, but the source is also available.

Typical usage is the following:
{code}
<cg:EventListener source="{logicTreeGrid.columns}" type="{CollectionEvent.CHANGE}" handler="eventHandler" />
{code}

The different with the description above is that you have to specify the event type, so it's not as generic.
but at least you get the event that caused the changed.

Otherwise, apart from doing reflection on the metadata of the source chain (which is what the compiler does), I can't see how it could work.

But maybe Gary is actually requesting a change in the mxml compiler, which is something else, because it would require to also adapt the various IDEs to "accept" this new syntax.

WDYT? 




was (Author: mamsellem):
BTW, there is another mxml tag in the cairngorm observer lib that is called EventListener, which is a binding-based event listener, that will listen to the event at the end of the binding chain.

the implementation is more complex that Observe, but the source is also available.

Typical usage is the following:

<cg:EventListener source="{logicTreeGrid.columns}" type="{CollectionEvent.CHANGE}" handler="eventHandler" />

The different with the description above is that you have to specify the event type, so it's not as generic.
but at least you get the event that caused the changed.

Otherwise, apart from doing reflection on the metadata of the source chain (which is what the compiler does), I can't see how it could work.

But maybe Gary is actually requesting a change in the mxml compiler, which is something else, because it would require to also adapt the various IDEs to "accept" this new syntax.

WDYT? 



> Give <fx:Binding /> an event handle.
> ------------------------------------
>
>                 Key: FLEX-34143
>                 URL: https://issues.apache.org/jira/browse/FLEX-34143
>             Project: Apache Flex
>          Issue Type: Improvement
>          Components: Data Binding
>            Reporter: Gary Yang
>   Original Estimate: 672h
>  Remaining Estimate: 672h
>
> 1st of all, Flex Binding is great!!!
> I am using it this way:
> >>>>>>>>>>>>>>>>>code>>>>>>>>>>>>
>  <fx:Script><![CDATA[
>         [Bindable("dataChange")]
>         public function get rowData():VLogicTreeGridRow{
>             return data as VLogicTreeGridRow;
>         }
>         private var _cellData:VLogicTreeGridCell;
>         [Bindable(event="cellDataChanged")]
>         public function get cellData():VLogicTreeGridCell{
>             return _cellData;
>         }
>         private function set rfrCellData( v:* ):void{
>             if( rowData != null
>                     && logicTreeGrid.columns != null && logicTreeGrid.columns.length > 0
>                     && rowData.cellList != null && rowData.cellList.length > 0
>                     ){
>                 var idx:int = logicTreeGrid.columns.getItemIndex( treeGridColLogic );
>                 var rt:VLogicTreeGridCell = rowData.cellList.getItemAt( idx ) as VLogicTreeGridCell;
>                 if( _cellData != rt ){
>                     _cellData = rt;
>                     dispatchEvent( new Event( "cellDataChanged" ) );
>                 }
>             }
>         }
>         ]]></fx:Script>
>     <ui:layout>
>         <s:HorizontalLayout paddingTop="2" paddingBottom="2" paddingLeft="2" paddingRight="2"/>
>     </ui:layout>
>     <fx:Binding source="logicTreeGrid.columns.length" destination="rfrCellData"/>
>     <fx:Binding source="rowData.cellList.length" destination="rfrCellData"/>
> <<<<<<<<<<<<<<<code<<<<<<<<<<<<
> Because the destination of Binding tag can only be setters, I have to use it this way if I want to handle changes from the Binding sources,  do you think it's possible to add a handle for Binding tag so that I can see exactly what event caused the change please?
> So that it can be like this
> >>>>>>>>>>>>>>>>>code>>>>>>>>>>>>
>         private function refreshCellData( ev:Event ):void{
>             if( ev is CollectionEvent ){
>                 
>             }
>             else if( ev is PropertyChangeEvent ){
>                 
>             }
>             if( rowData != null
>                     && logicTreeGrid.columns != null && logicTreeGrid.columns.length > 0
>                     && rowData.cellList != null && rowData.cellList.length > 0
>                     ){
>                 var idx:int = logicTreeGrid.columns.getItemIndex( treeGridColLogic );
>                 var rt:VLogicTreeGridCell = rowData.cellList.getItemAt( idx ) as VLogicTreeGridCell;
>                 if( _cellData != rt ){
>                     _cellData = rt;
>                     dispatchEvent( new Event( "cellDataChanged" ) );
>                 }
>             }
>         }
>         ]]></fx:Script>
>     <ui:layout>
>         <s:HorizontalLayout paddingTop="2" paddingBottom="2" paddingLeft="2" paddingRight="2"/>
>     </ui:layout>
>     <fx:Binding source="logicTreeGrid.columns.length" changeHandle="refreshCellData"/>
>     <fx:Binding source="rowData.cellList.length" changeHandle="refreshCellData"/>
> <<<<<<<<<<<<<<<code<<<<<<<<<<<<
> This is going to be very useful!!!



--
This message was sent by Atlassian JIRA
(v6.2#6252)