On 1/7/19, 10:31 AM, "Harbs" <harbs.li...@gmail.com> wrote:

    Details:
    
      <sp:ActionButton id="actionButton" click="actionClick()"
            icon="#spectrum-css-icon-ChevronRightMedium"
            iconClass="spectrum-Icon spectrum-Icon--sizeXS"
            dataProvider="{comboProvider}" change="actionChange()"/>
    
    Requiring client code to check for defaultPrevented is bad. actionClick() 
should not run.
    
    I’m trying to prevent that. Event listeners added in addedToParent are run 
after event listener declared in MXML. That’s true even if do this:
    element.addEventListener('click',elementClickedForMenu,true);

There is no capture phase at the target.  To implement a capture phase 
listener, you must listen to the parent of the target.  If that still doesn't 
work, then there is a bug.
    
    Adding the event listener in the constructor makes it fire first, but I was 
having trouble canceling the subsequent ones.
    
    Capture phase seems to not help at all. It would probably help if I could 
attach the event listener to the parent, but I can’t do that inside the 
component.
    
    While responding to this email I realized that I had tried everything 
except stopImmediatePropogation.
    
    That was the answer.
    
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Funhurdle%2Fspectrum-royale%2Fblob%2F21ae0a6d901a8eb4f461ce42def34e870554ec34%2FSpectrum%2Fsrc%2Fcom%2Funhurdle%2Fspectrum%2FActionButton.as%23L103&amp;data=02%7C01%7Caharui%40adobe.com%7Caf6025fd64a444fed60e08d674ce609e%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636824827066165754&amp;sdata=FYcQz2jXgV4wXb8iMO9etQ9xVKDGbsbGnh2xMJRl4h4%3D&amp;reserved=0
 
<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Funhurdle%2Fspectrum-royale%2Fblob%2F21ae0a6d901a8eb4f461ce42def34e870554ec34%2FSpectrum%2Fsrc%2Fcom%2Funhurdle%2Fspectrum%2FActionButton.as%23L103&amp;data=02%7C01%7Caharui%40adobe.com%7Caf6025fd64a444fed60e08d674ce609e%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636824827066165754&amp;sdata=FYcQz2jXgV4wXb8iMO9etQ9xVKDGbsbGnh2xMJRl4h4%3D&amp;reserved=0>
    
    Thanks!
    
    > On Jan 7, 2019, at 8:11 PM, Alex Harui <aha...@adobe.com.INVALID> wrote:
    > 
    > What's wrong with Olaf's answer?
    > 
    > preventDefault() should only work on cancelable events, and in theory if 
I remember the spec corrrectly, click is not cancelable.  The other listeners 
must also check isDefaultPrevented().
    > 
    > stopPropagation and stopImmediatePropagation are intended to keep other 
listeners from even getting called.  We want stopProp and stopImmedateProp to 
work in Royale so if it doesn't, it needs to be fixed.
    > 
    > I think the full answer to your scenario is to use capture phase and call 
stopProp.
    > 
    > My 2 cents,
    > -Alex
    > 
    > On 1/7/19, 7:22 AM, "Harbs" <harbs.li...@gmail.com 
<mailto:harbs.li...@gmail.com>> wrote:
    > 
    >    The only way I see of preventing the event from firing is to abort 
fireListenerOverride in HTMLElementWrapper.
    > 
    >    I can set defaultPrevented by attaching an event listener to the 
element in the constructor of my class.
    > 
    >    The question is whether we should abort the event dispatching if the 
event is defaultPrevented.
    > 
    >    In short, we can solve this problem by adding to the beginning of 
HTMLElementWrapper.fireListenerOverride:
    > 
    >    if(eventObject.defaultPrevented)return false;
    > 
    >    The question is whether this is something we should be doing.
    > 
    >    I have no other ideas of how to solve this problem.
    > 
    >    Harbs
    > 
    >> On Jan 7, 2019, at 4:37 PM, Olaf Krueger <m...@olafkrueger.net> wrote:
    >> 
    >> What's about setting up a default handler which always handles the click
    >> event.
    >> Depending on your conditions, maybe calling stopPropagation() or
    >> stopImmediatePropagation() will prevent further propagation?
    >> 
    >> Maybe this helps,
    >> Olaf
    >> 
    >> 
    >> 
    >> --
    >> Sent from: 
https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-royale-development.20373.n8.nabble.com%2F&amp;data=02%7C01%7Caharui%40adobe.com%7Caf6025fd64a444fed60e08d674ce609e%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636824827066165754&amp;sdata=AXtaj%2FZnolmNjqWaFJ809giSfc1H7X7GeU9tWmaWdRY%3D&amp;reserved=0
 
<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-royale-development.20373.n8.nabble.com%2F&amp;data=02%7C01%7Caharui%40adobe.com%7Caf6025fd64a444fed60e08d674ce609e%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636824827066165754&amp;sdata=AXtaj%2FZnolmNjqWaFJ809giSfc1H7X7GeU9tWmaWdRY%3D&amp;reserved=0>
    

Reply via email to