Add MouseEntered/MouseLeft for Windows, X11, Wayland, & Cocoa
This commit is contained in:
parent
705f5f50fa
commit
db45e58390
5 changed files with 33 additions and 11 deletions
|
|
@ -683,6 +683,8 @@ unsafe fn NSEventToEvent(window: &Window, nsevent: id) -> Option<Event> {
|
|||
appkit::NSLeftMouseUp => { Some(Event::MouseInput(ElementState::Released, MouseButton::Left)) },
|
||||
appkit::NSRightMouseDown => { Some(Event::MouseInput(ElementState::Pressed, MouseButton::Right)) },
|
||||
appkit::NSRightMouseUp => { Some(Event::MouseInput(ElementState::Released, MouseButton::Right)) },
|
||||
appkit::NSMouseEntered => { Some(Event::MouseEntered) },
|
||||
appkit::NSMouseExited => { Some(Event::MouseLeft) },
|
||||
appkit::NSMouseMoved |
|
||||
appkit::NSLeftMouseDragged |
|
||||
appkit::NSOtherMouseDragged |
|
||||
|
|
|
|||
|
|
@ -125,11 +125,14 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
}
|
||||
|
||||
winapi::WM_MOUSEMOVE => {
|
||||
use events::Event::MouseMoved;
|
||||
use events::Event::{MouseEntered, MouseMoved};
|
||||
CONTEXT_STASH.with(|context_stash| {
|
||||
let mut context_stash = context_stash.borrow_mut();
|
||||
if let Some(context_stash) = context_stash.as_mut() {
|
||||
context_stash.mouse_in_window = true;
|
||||
if !context_stash.mouse_in_window {
|
||||
send_event(window, MouseEntered);
|
||||
context_stash.mouse_in_window = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -142,10 +145,14 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
winapi::WM_MOUSELEAVE => {
|
||||
use events::Event::MouseLeft;
|
||||
CONTEXT_STASH.with(|context_stash| {
|
||||
let mut context_stash = context_stash.borrow_mut();
|
||||
if let Some(context_stash) = context_stash.as_mut() {
|
||||
context_stash.mouse_in_window = false;
|
||||
if context_stash.mouse_in_window {
|
||||
send_event(window, MouseLeft);
|
||||
context_stash.mouse_in_window = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue