slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.55k stars 601 forks source link

feat: disable interaction for some components #4124

Closed std-microblock closed 9 months ago

std-microblock commented 11 months ago

like css pointer-events: none;, it's useful for animations sometimes

ogoffart commented 11 months ago

Thanks for your request: There is a enabled property on TouchArea and most widgets.

There is a tracking issue to have properties that propagate that would make sense for enabled https://github.com/slint-ui/slint/issues/2338

ogoffart commented 11 months ago

Although enabled also change the look of widget to make them visibly enabled.

Another option would be to have a TouchArea on top which intercept the event while animating?

std-microblock commented 11 months ago

That would be painful... the enabled property also doesn't meet my need, as it also controls the visibility of the components

ogoffart commented 9 months ago

Having components that are disabled without any indication is weird. You can do what you want with a TouchArea on top of the component that intercept the events that you can make visible when you want to disable it.

component MakeDisable {
   in property <bool> disabled;
   @children
   if disabled: TouchArea {}
}