Skip to content

Commit

Permalink
Send a MouseExit event when the mouse leaves the window
Browse files Browse the repository at this point in the history
Fixes #989
  • Loading branch information
ogoffart committed Mar 1, 2022
1 parent 9a6c306 commit f7a0fda
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ All notable changes to this project will be documented in this file.
### Added

- C++ interpreter API: added a `Value::Value(int)` constructor
- Globals Singleton may now refer to other global singletons

### Fixed

- `TouchArea::has-hover` is now properly set to false when the mouse leaves the window.

## [0.2.0] - 2022-02-10

Expand Down
3 changes: 1 addition & 2 deletions internal/backends/gl/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,7 @@ fn process_window_event(
}
WindowEvent::CursorLeft { .. } => {
// On the html canvas, we don't get the mouse move or release event when outside the canvas. So we have no choice but canceling the event
#[cfg(target_arch = "wasm32")]
if *pressed {
if cfg!(target_arch = "wasm32") || !*pressed {
corelib::animations::update_animations();
*pressed = false;
runtime_window.process_mouse_input(MouseEvent::MouseExit);
Expand Down
5 changes: 5 additions & 0 deletions internal/backends/qt/qt_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ cpp! {{
rust_window.mouse_event(MouseEvent::MouseWheel{pos, delta})
});
}
void leaveEvent(QEvent *) override {
rust!(Slint_mouseLeaveEvent [rust_window: &QtWindow as "void*"] {
rust_window.mouse_event(MouseEvent::MouseExit)
});
}

void keyPressEvent(QKeyEvent *event) override {
uint modifiers = uint(event->modifiers());
Expand Down

0 comments on commit f7a0fda

Please sign in to comment.