diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rs index 343216860..e03f03ba2 100644 --- a/window/src/os/macos/window.rs +++ b/window/src/os/macos/window.rs @@ -918,6 +918,18 @@ impl WindowView { } } + extern "C" fn did_become_key(this: &mut Object, _sel: Sel, _id: id) { + if let Some(this) = Self::get_this(this) { + this.inner.borrow_mut().callbacks.focus_change(true); + } + } + + extern "C" fn did_resign_key(this: &mut Object, _sel: Sel, _id: id) { + if let Some(this) = Self::get_this(this) { + this.inner.borrow_mut().callbacks.focus_change(false); + } + } + // Switch the coordinate system to have 0,0 in the top left extern "C" fn is_flipped(_this: &Object, _sel: Sel) -> BOOL { YES @@ -1296,6 +1308,15 @@ impl WindowView { Self::did_resize as extern "C" fn(&mut Object, Sel, id), ); + cls.add_method( + sel!(windowDidBecomeKey:), + Self::did_become_key as extern "C" fn(&mut Object, Sel, id), + ); + cls.add_method( + sel!(windowDidResignKey:), + Self::did_resign_key as extern "C" fn(&mut Object, Sel, id), + ); + cls.add_method( sel!(mouseMoved:), Self::mouse_moved_or_dragged as extern "C" fn(&mut Object, Sel, id),