rust_macios/appkit/
ns_status_bar_button.rs1#![allow(trivial_casts)]
2
3use objc::{msg_send, sel, sel_impl};
4
5use crate::{object, objective_c_runtime::traits::PNSObject, utils::to_bool};
6
7use super::{interface_impl, ActionHandler, INSButton, INSControl, INSResponder, INSView};
8
9object! {
10 unsafe pub struct NSStatusBarButton;
12}
13
14pub static mut NSSTATUS_BAR_BUTTON_HANDLER: Option<ActionHandler> = None;
16
17impl NSStatusBarButton {
18 pub fn set_action<F: Fn() + Send + Sync + 'static>(&mut self, action: F) {
24 let this = self.m_self();
25 let handler = ActionHandler::new(unsafe { &*this }, action);
26 unsafe {
27 NSSTATUS_BAR_BUTTON_HANDLER = Some(handler);
28 }
29 }
30}
31
32impl INSResponder for NSStatusBarButton {}
33
34impl INSView for NSStatusBarButton {}
35
36impl INSControl for NSStatusBarButton {}
37
38impl INSButton for NSStatusBarButton {}
39
40#[interface_impl(NSButton)]
41impl NSStatusBarButton {
42 #[property]
44 pub fn appears_disabled(&self) -> bool {
45 unsafe { to_bool(msg_send![self.m_self(), appearsDisabled]) }
46 }
47}