mirror of
https://github.com/rust-windowing/winit.git
synced 2026-08-29 21:00:04 -04:00
Allow preventing the creation of the default menu (#1923)
* Allow preventing the creation of the default menu * Use more grammar friendly naming * Update the changelog
This commit is contained in:
@@ -17,6 +17,8 @@ pub struct AuxDelegateState {
|
||||
/// after the app has finished launching. If the activation policy is set earlier, the
|
||||
/// menubar is initially unresponsive on macOS 10.15 for example.
|
||||
pub activation_policy: ActivationPolicy,
|
||||
|
||||
pub create_default_menu: bool,
|
||||
}
|
||||
|
||||
pub struct AppDelegateClass(pub *const Class);
|
||||
@@ -56,6 +58,7 @@ extern "C" fn new(class: &Class, _: Sel) -> id {
|
||||
AUX_DELEGATE_STATE_NAME,
|
||||
Box::into_raw(Box::new(RefCell::new(AuxDelegateState {
|
||||
activation_policy: ActivationPolicy::Regular,
|
||||
create_default_menu: true,
|
||||
}))) as *mut c_void,
|
||||
);
|
||||
this
|
||||
|
||||
@@ -289,9 +289,12 @@ impl AppState {
|
||||
};
|
||||
HANDLER.set_ready();
|
||||
HANDLER.waker().start();
|
||||
// The menubar initialization should be before the `NewEvents` event, to allow overriding
|
||||
// of the default menu in the event
|
||||
menu::initialize();
|
||||
let create_default_menu = unsafe { get_aux_state_mut(app_delegate).create_default_menu };
|
||||
if create_default_menu {
|
||||
// The menubar initialization should be before the `NewEvents` event, to allow
|
||||
// overriding of the default menu even if it's created
|
||||
menu::initialize();
|
||||
}
|
||||
HANDLER.set_in_callback(true);
|
||||
HANDLER.handle_nonuser_event(EventWrapper::StaticEvent(Event::NewEvents(
|
||||
StartCause::Init,
|
||||
|
||||
Reference in New Issue
Block a user