Click Event in Item Renderer... firing a second barrel ?!

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Click Event in Item Renderer... firing a second barrel ?!

jamiebadman
Hi,

Can someone help ?

I've created a custom item renderer for a tree in which I have a
listener on the mouse click event. Unfortunately, though, the main
app code also needs to act on the click event - I have the tree
defined as:

<mx:Tree id="tvCompanies" itemRenderer="CompanyTreeItemRenderer"
click="getCompanyDetail()" dataProvider="{myData.companies}" />

The event is being picked up by the renderer and the function in
there is working fine - but 'getCompanyDetail' isn't firing off at
all.

Any ideas ?

Thanks,

Jamie.







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[hidden email]
    mailto:[hidden email]

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply | Threaded
Open this post in threaded view
|

Re: Click Event in Item Renderer... firing a second barrel ?!

flex.helleman
Sould you be listening for the change event?



--- In [hidden email], "jamiebadman" <jamie.badman@...> wrote:

>
> Hi,
>
> Can someone help ?
>
> I've created a custom item renderer for a tree in which I have a
> listener on the mouse click event. Unfortunately, though, the main
> app code also needs to act on the click event - I have the tree
> defined as:
>
> <mx:Tree id="tvCompanies" itemRenderer="CompanyTreeItemRenderer"
> click="getCompanyDetail()" dataProvider="{myData.companies}" />
>
> The event is being picked up by the renderer and the function in
> there is working fine - but 'getCompanyDetail' isn't firing off at
> all.
>
> Any ideas ?
>
> Thanks,
>
> Jamie.
>






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[hidden email]
    mailto:[hidden email]

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply | Threaded
Open this post in threaded view
|

Re: Click Event in Item Renderer... firing a second barrel ?!

Derrick Grigg
In reply to this post by jamiebadman
Since both events 'click' events, the event is bubbling up from the
renderer to the main application. In order to stop it you need to do
an event.preventDefault(), event.stopPropagation() or
event.stopImmediatePropagation() in the first event handler to stop
the event bubbling.

http://livedocs.macromedia.com/flex/2/langref/flash/events/Event.html

http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/common/html/w
whelp.htm?context=LiveDocs_Parts&file=00000475.html



Derrick Grigg
--------------
www.dgrigg.com






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[hidden email]
    mailto:[hidden email]

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply | Threaded
Open this post in threaded view
|

Re: Click Event in Item Renderer... firing a second barrel ?!

comfuture21
In reply to this post by jamiebadman
try mx.events.ItemClickEvent

<mx:Script>
<![CDATA[
  import mx.events.ItemClickEvent;

  public function getCompanyDetail(event:ItemClickEvent):void
  {
    // your code here...
  }
]]>
</mx:Script>
<mx:Tree id="tvCompanies" itemRenderer="CompanyTreeItemRenderer"
itemClick="getCompanyDetail()" dataProvider="{myData.companies}" />

--- In [hidden email], "jamiebadman" <jamie.badman@...> wrote:

>
> Hi,
>
> Can someone help ?
>
> I've created a custom item renderer for a tree in which I have a
> listener on the mouse click event. Unfortunately, though, the main
> app code also needs to act on the click event - I have the tree
> defined as:
>
> <mx:Tree id="tvCompanies" itemRenderer="CompanyTreeItemRenderer"
> click="getCompanyDetail()" dataProvider="{myData.companies}" />
>
> The event is being picked up by the renderer and the function in
> there is working fine - but 'getCompanyDetail' isn't firing off at
> all.
>
> Any ideas ?
>
> Thanks,
>
> Jamie.
>







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[hidden email]
    mailto:[hidden email]

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/