JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.42k stars 1.12k forks source link

web: Modifier should support mouse events similar to Desktop Compose #1030

Closed bitspittle closed 2 years ago

bitspittle commented 2 years ago

In particular: https://github.com/JetBrains/compose-jb/tree/master/tutorials/Mouse_Events

If for some reason, the API intentionally diverges due to differences in how web and desktop work, that's fine -- but there needs to be a way to support onMouseEnter, onMouseLeave, and onMouseMove at the very least.

bitspittle commented 2 years ago

Note: I fully expect for you to diverge from how I'm doing it, but here's what I'm doing at the moment as a workaround:

https://github.com/bitspittle/kobweb/blob/main/lib/compose-ext/src/jsMain/kotlin/kobweb/compose/ui/ModifierExtensions.kt#L64

eymar commented 2 years ago

Perhaps I don't get the question. Let's figure it out.

Currently there is a way to add listeners that you're asking about: onMouseEnter onMouseLeave onMouseMove

And as I see in your code snippet you're already using them.

So my question is: What kind of mouse events support would you like to have?

bitspittle commented 2 years ago

My apologies for the lack of clarity, thanks for following up with those questions.

I updated the title, hopefully it's more clear now. I think mouse events should be exposed through the Modifier class, beyond just clickable which is available right now.

FWIW, the code I linked to it in a module in my project called compose-ext which I'm hoping one day to delete entirely. I don't think it should exist - I'm just patching what I think are the current holes in the Web Compose API so I can keep moving.

eymar commented 2 years ago

closing this issue. Reason: since 1.0.0 compose.web.widgets module was deprecated.

okushnikov commented 9 hours ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.