Giter VIP home page Giter VIP logo

Comments (5)

Muchaszewski avatar Muchaszewski commented on August 27, 2024 1

From what I tested it behaves like that when the button is a child of a div. It looks like the events are handled by the button instead of a div, and since you do not perform TrickleDown the event is probably stopped by the button, just registering an empty event.

<div onPointerDown={() => {console.log("onPointerDown")}}>
  <button>
    Button
  </button>
</div>

from core.

KurtGokhan avatar KurtGokhan commented on August 27, 2024 1

The newest version of core and renderer now allow TrickleDown variant of all events like onPointerDownCapture

from core.

KurtGokhan avatar KurtGokhan commented on August 27, 2024

I tried this with UIToolkit (I think that is how you tested it too). For div, it works as expected:

image

Except onPointerCancel because I don't know how to test it. Also onPointerUp and onMouseUp don't fire if you leave the element when holding the mouse down.

For button it is as you said. onPointerDown doesn't work probably because Unity handles that internally. According to this forum thread the event should be registered with TrickleDown, and ReactUnity does not do that. It is similar to capture in browsers. So I will add a capture variant to every event.

Drag events are for editor UI only. They don't work in runtime afaik. A while ago I did a prototype on how they work, so they should be working (in editor).

I don't know why the div works different for you. Can you see any difference that may cause it?

from core.

Muchaszewski avatar Muchaszewski commented on August 27, 2024

That works! Thank you :)

But I have to argue if that would not be confusing to have so many different events. At the end of the day should perform the same exact action, and there is almost no difference for the end user.

from core.

KurtGokhan avatar KurtGokhan commented on August 27, 2024

React for Web also has the same naming convention for capture events (for example onClick and onClickCapture). Since UIToolkit is inspired by HTML, I think it is acceptable to have this.

There may be significant differences for the end user, and I can't know which variant the user needs. So, I think it is better to present both options. For example, parent element will receive the event first in capture phase, wherease in bubble phase child element will receive the event first.

Closing this as solved.

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.