From 4372c047e64971f7404f433d382c8a73f0871cb1 Mon Sep 17 00:00:00 2001 From: svoss Date: Wed, 25 Sep 2019 06:36:55 -0700 Subject: [PATCH] Adds setTarget to buttons and menu items, these are required in many cases --- cocoa/src/appkit.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cocoa/src/appkit.rs b/cocoa/src/appkit.rs index e8f08f4..8e96460 100644 --- a/cocoa/src/appkit.rs +++ b/cocoa/src/appkit.rs @@ -821,6 +821,7 @@ pub trait NSMenuItem: Sized { unsafe fn initWithTitle_action_keyEquivalent_(self, title: id, action: SEL, key: id) -> id; unsafe fn setKeyEquivalentModifierMask_(self, mask: NSEventModifierFlags); unsafe fn setSubmenu_(self, submenu: id); + unsafe fn setTarget_(self, target: id); } impl NSMenuItem for id { @@ -835,6 +836,10 @@ impl NSMenuItem for id { unsafe fn setSubmenu_(self, submenu: id) { msg_send![self, setSubmenu:submenu] } + + unsafe fn setTarget_(self, target: id) { + msg_send![self, setTarget:target] + } } pub type NSWindowDepth = libc::c_int; @@ -2963,6 +2968,8 @@ pub trait NSButton: Sized { msg_send![class!(NSButton), alloc] } unsafe fn initWithFrame_(self, frameRect: NSRect) -> id; + unsafe fn setTarget_(self, target: id /* Instance */); + unsafe fn setAction_(self, selector: objc::runtime::Sel /* (Instance *) */); } impl NSButton for id { @@ -2978,6 +2985,13 @@ impl NSButton for id { unsafe fn setImage_(self, img: id /* (NSImage *) */) { msg_send![self, setImage:img] } + unsafe fn setTarget_(self, target: id /* (Instance *) */) { + msg_send![self, setTarget:target] + } + + unsafe fn setAction_(self, selector: objc::runtime::Sel /* (Instance method *) */) { + msg_send![self, setAction:selector]; + } } pub trait NSImage: Sized {