Comments (5)
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.
The newest version of core and renderer now allow TrickleDown
variant of all events like onPointerDownCapture
from core.
I tried this with UIToolkit (I think that is how you tested it too). For div
, it works as expected:
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.
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.
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)
- Consider supporting 2023.2.0f1 HOT 1
- How get react global value from c#? HOT 4
- When transform rotating an element via css, it rotates counter clockwise, not clockwise
- souce on image element gives a Typescript error HOT 3
- TS2339: Property 'scroll' does not exist on type 'JSX.IntrinsicElements' HOT 1
- Auto-Reload after changes in code are not reflected or automaticaly updated. HOT 1
- Created canvases should inherit properties from the main canvas HOT 1
- What's the best practice to use Router? HOT 2
- Chinese didn't render in ReactUnity canvas HOT 2
- Inconsistent element rendering HOT 4
- [CSS] "width: 100%" seems to not work inside of Unity HOT 1
- compare with react-unity-webgl HOT 1
- TypeScript is missing the definition of `direction` prop in `scroll` element HOT 1
- UI Toolkit renderer is missing css properties like `background-size` HOT 2
- BUG [TypeScript] `UnityEngine.Networking` has no exported member `UnityWebRequest` HOT 1
- Hot reloading? HOT 3
- Websockets? HOT 4
- [BUG] UI Toolkit `:active` does not work HOT 2
- [BUG] `decodeURIComponent` does not work in Android HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.