rust_macios/appkit/
ns_button.rs1use objc::{msg_send, sel, sel_impl};
2
3use crate::{foundation::NSString, objective_c_runtime::traits::FromId};
4pub(crate) use crate::{object, objective_c_runtime::macros::interface_impl};
5
6use super::{INSControl, INSResponder, INSView, NSImage};
7
8object! {
9 unsafe pub struct NSButton;
11}
12
13impl INSResponder for NSButton {}
14
15impl INSView for NSButton {}
16
17impl INSControl for NSButton {}
18
19#[interface_impl(NSControl)]
20impl NSButton {
21 #[property]
26 pub fn title(&self) -> NSString {
27 unsafe { msg_send![self.m_self(), title] }
28 }
29
30 #[property]
32 pub fn set_title(&self, title: NSString) {
33 unsafe { msg_send![self.m_self(), setTitle: title] }
34 }
35
36 #[property]
41 pub fn image(&self) -> NSImage {
42 unsafe { NSImage::from_id(msg_send![self.m_self(), image]) }
43 }
44
45 #[property]
51 pub fn set_image(&self, image: NSImage) {
52 unsafe { msg_send![self.m_self(), setImage: image] }
53 }
54}