1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use objc::{msg_send, sel, sel_impl};
use crate::{foundation::NSString, objective_c_runtime::traits::FromId};
pub(crate) use crate::{object, objective_c_runtime::macros::interface_impl};
use super::{INSControl, INSResponder, INSView, NSImage};
object! {
/// A control that defines an area on the screen that a user clicks to trigger an action.
unsafe pub struct NSButton;
}
impl INSResponder for NSButton {}
impl INSView for NSButton {}
impl INSControl for NSButton {}
#[interface_impl(NSControl)]
impl NSButton {
/* Configuring Buttons
*/
/// The title displayed on the button when it’s in an off state.
#[property]
pub fn title(&self) -> NSString {
unsafe { msg_send![self.m_self(), title] }
}
/// Sets the title displayed on the button when it’s in an off state.
#[property]
pub fn set_title(&self, title: NSString) {
unsafe { msg_send![self.m_self(), setTitle: title] }
}
/* Configuring Button Images
*/
/// The image that appears on the button when it’s in an off state, or nil if there is no such image.
#[property]
pub fn image(&self) -> NSImage {
unsafe { NSImage::from_id(msg_send![self.m_self(), image]) }
}
/// Sets the image that appears on the button when it’s in an off state, or nil if there is no such image.
///
/// # Arguments
///
/// * `image` - The new image.
#[property]
pub fn set_image(&self, image: NSImage) {
unsafe { msg_send![self.m_self(), setImage: image] }
}
}