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.56k stars 604 forks source link

Widgets react to all mouse buttons when using Qt backend #4975

Closed notfirefox closed 7 months ago

notfirefox commented 7 months ago

Steps to reproduce The issue can be reproduced on Linux using the example gallery application.

  1. git clone https://github.com/slint-ui/slint
  2. cd examples/gallery
  3. cargo run

Expected behavior Components such as

should not react with the primary action when someone presses any mouse button that is not the left mouse button, e.g. the Button widget is not supposed to be clicked when someone right clicks.

Actual behavior One can activate the Button using right click, one can select a Checkbox using mouse button 5, etc.

Platform Fedora Linux 40, Rust, Qt Backend, Wayland

ogoffart commented 7 months ago

Thanks for filling a bug report. Indeed in the Qt Widget we don't check the MouseEvent's button as we should in the input_event function. For example for Button, in this function https://github.com/slint-ui/slint/blob/0e01068ff52c2135363bdbfa59f145cd56beea11/internal/backends/qt/qt_widgets/button.rs#L246