mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 06:11:30 +11:00
Added mose move event
This commit is contained in:
parent
d0d787bff0
commit
421beefe67
|
@ -14,6 +14,7 @@ use core_foundation::string::CFString;
|
||||||
use core_foundation::bundle::{CFBundleGetBundleWithIdentifier, CFBundleGetFunctionPointerForName};
|
use core_foundation::bundle::{CFBundleGetBundleWithIdentifier, CFBundleGetFunctionPointerForName};
|
||||||
|
|
||||||
pub struct Window {
|
pub struct Window {
|
||||||
|
view: id,
|
||||||
context: id,
|
context: id,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +87,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
let window = Window {
|
let window = Window {
|
||||||
|
view: view,
|
||||||
context: context,
|
context: context,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -123,6 +125,7 @@ impl Window {
|
||||||
let title = NSString::alloc(nil).init_str(title);
|
let title = NSString::alloc(nil).init_str(title);
|
||||||
window.setTitle_(title);
|
window.setTitle_(title);
|
||||||
window.center();
|
window.center();
|
||||||
|
window.setAcceptsMouseMovedEvents_(true);
|
||||||
Some(window)
|
Some(window)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,7 +205,7 @@ impl Window {
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
unsafe {
|
unsafe {
|
||||||
use {MouseInput, Pressed, Released, LeftMouseButton, RightMouseButton};
|
use {MouseInput, Pressed, Released, LeftMouseButton, RightMouseButton, MouseMoved};
|
||||||
let event = NSApp().nextEventMatchingMask_untilDate_inMode_dequeue_(
|
let event = NSApp().nextEventMatchingMask_untilDate_inMode_dequeue_(
|
||||||
NSAnyEventMask as u64,
|
NSAnyEventMask as u64,
|
||||||
NSDate::distantPast(nil),
|
NSDate::distantPast(nil),
|
||||||
|
@ -215,7 +218,11 @@ impl Window {
|
||||||
NSLeftMouseUp => { events.push(MouseInput(Released, LeftMouseButton)); },
|
NSLeftMouseUp => { events.push(MouseInput(Released, LeftMouseButton)); },
|
||||||
NSRightMouseDown => { events.push(MouseInput(Pressed, RightMouseButton)); },
|
NSRightMouseDown => { events.push(MouseInput(Pressed, RightMouseButton)); },
|
||||||
NSRightMouseUp => { events.push(MouseInput(Released, RightMouseButton)); },
|
NSRightMouseUp => { events.push(MouseInput(Released, RightMouseButton)); },
|
||||||
NSMouseMoved => { },
|
NSMouseMoved => {
|
||||||
|
let window_point = event.locationInWindow();
|
||||||
|
let view_point = self.view.convertPoint_fromView_(window_point, nil);
|
||||||
|
events.push(MouseMoved((view_point.x as int, view_point.y as int)));
|
||||||
|
},
|
||||||
NSKeyDown => { },
|
NSKeyDown => { },
|
||||||
NSKeyUp => { },
|
NSKeyUp => { },
|
||||||
NSFlagsChanged => { },
|
NSFlagsChanged => { },
|
||||||
|
@ -236,8 +243,8 @@ impl Window {
|
||||||
NSAnyEventMask as u64,
|
NSAnyEventMask as u64,
|
||||||
NSDate::distantFuture(nil),
|
NSDate::distantFuture(nil),
|
||||||
NSDefaultRunLoopMode,
|
NSDefaultRunLoopMode,
|
||||||
true);
|
false);
|
||||||
NSApp().sendEvent_(event);
|
|
||||||
self.poll_events()
|
self.poll_events()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue