royale-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carlos Rovira <carlosrov...@apache.org>
Subject Re: List Item renderer Click event finds a component in its way
Date Tue, 03 Jul 2018 07:58:11 GMT
Hi Yishay,

the following code is from JewelExample, you can run it to get the final
effect for convenience.

Problem: The new Drawer component has a Navigation component. Navigation is
a List that implements navigation behavior

<j:Drawer id="drawer">
...
<j:DrawerContent>
<j:Navigation click="clickHandler(event)" className="navIconLinItemRenderer"
>
<j:beads>
<js:ConstantBinding
sourceID="mainNavigationModel"
sourcePropertyName="containerDrawerNavigation"
destinationPropertyName="dataProvider"/>
</j:beads>
</j:Navigation>

and the click handler:

<fx:Script>
<![CDATA[
import org.apache.royale.jewel.supportClasses.INavigationRenderer;
private function clickHandler(event:MouseEvent):void
{
var renderer:INavigationRenderer = event.target as INavigationRenderer;
if (renderer)
{
var link:String = renderer.href;
main.showContent(link);
}
}
]]>
</fx:Script>

Navigation has NavigationLinkItemRenderer that use to handle "text" and
"href" (this props will change the name soon to something more generic)
since is an INavigationRenderer.

In JewlExample, I'm using an NavigationIconLinkItemRenderer that is an MXML
extension that adds an Icon and Span components.

When the user clicks on the Icon/Span components and the clickHandler gets
called, event.target is one of those components and not the ItemRenderer so
"renderer" is not the INavigationRenderer. If I click in some free space in
the renderer, all is ok, renderer is INavigationRenderer and renderer gets
the right value, entering the "if" and calling main.showContent(link), that
by the way is a container that has some "screens" or organized content and
hides all content while make visible only the selected content.

So how can should deal with this kind of issue?

Expected behavior: Users can add components to an item renderer (more
icons, more text...) and all this components should not interfere by
default with the click event. Only the components that has a click event
defined should take precedence over the item renderer click event.

Maybe I'm wrong and is not a click handler, but an itemClicked? but as I
stated "itemClicked" is not part of the events managed by List. If we want
to configure this event in a List in mxml we need to add this to List.

Thanks for your help

Carlos




2018-07-03 6:37 GMT+02:00 Yishay Weiss <yishayjobs@hotmail.com>:

> Hi  Carlos,
>
>
>
> Can you post some example app so I can understand the problem? We’re using
> List in several places in our app, including label and icon renderers, and
> haven’t had this problem.
>
>
>
> ________________________________
> From: carlos.rovira@gmail.com <carlos.rovira@gmail.com> on behalf of
> Carlos Rovira <carlosrovira@apache.org>
> Sent: Tuesday, July 3, 2018 12:44:17 AM
> To: dev@royale.apache.org
> Subject: Re: List Item renderer Click event finds a component in its way
>
> Hi Yishay,
>
> thanks for let me know about it. I'm playing with it but I didn't get to
> work.
> The case is that maybe List component is not ready for this yet.
>
> * event.currentTarget seems not exists in ItemRenderers
> * I can use "itemClicked" event in a MXML List (I think is not set the
> metadata and the rest of wiring)
> * List change event doesn't work as well.
>
>  Hope you or other could point me to a more elegant solution since right
> now, since for me the actual solution is a hack that must be converted to
> something more final.
>
> Thanks
>
>
>
> 2018-07-02 16:38 GMT+02:00 Yishay Weiss <yishayjobs@hotmail.com>:
>
> > Take a look at ItemRendererMouseController.handleMouseUp() in Basic. It
> > uses currentTarget.
> >
> >
> >
> >
> >
> >
> >
> > ________________________________
> > From: carlos.rovira@gmail.com <carlos.rovira@gmail.com> on behalf of
> > Carlos Rovira <carlosrovira@apache.org>
> > Sent: Monday, July 2, 2018 5:27:08 PM
> > To: dev@royale.apache.org
> > Subject: List Item renderer Click event finds a component in its way
> >
> > Hi,
> >
> > what's the best way to handle a click event in a List when the Item
> > renderer has some components that can interfere in the click event?
> >
> > I have an icon and a Label in the item renderer and if I click on one of
> > those "event.target" is logically set to this components.
> >
> > How to make "event.target" always resolve to the item-renderer, even if I
> > click in the label or the icon.
> > If the label or the icon has a click event, then clicking on one of those
> > components should call it's own click handler, but if nothing is set up,
> a
> > click in any part of the renderer should call the list click event
> handler.
> >
> > In JS I can set pointer-events : none for sub components in item
> renderers
> > but does not seems the best way to handle this
> >
> > thanks
> >
> > --
> > Carlos Rovira
> > http://about.me/carlosrovira
> >
>
>
>
> --
> Carlos Rovira
> http://about.me/carlosrovira
>



-- 
Carlos Rovira
http://about.me/carlosrovira

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message