this is the numeric argument to the command.
This function decides which method to use to access the menu
depending on FRAME's terminal device. On X displays, it calls
-`x-menu-bar-open'; on Windows, `w32-menu-bar-open'; otherwise it
-calls either `popup-menu' or `tmm-menubar' depending on whether
-`tty-menu-open-use-tmm' is nil or not.
+`x-menu-bar-open'; on Windows, `w32-menu-bar-open';
+on NS, `ns-menu-bar-open'; otherwise it calls either `popup-menu'
+or `tmm-menubar' depending on whether `tty-menu-open-use-tmm'
+is nil or not.
If FRAME is nil or not given, use the selected frame."
(interactive
(cond
((eq type 'x) (x-menu-bar-open frame))
((eq type 'w32) (w32-menu-bar-open frame))
+ ((eq type 'ns) (ns-menu-bar-open frame))
((and (null tty-menu-open-use-tmm)
(not (zerop (or (frame-parameter nil 'menu-bar-lines) 0))))
;; Make sure the menu bar is up to date. One situation where
ns_update_menubar (f, deep_p);
}
+void
+ns_activate_menubar (struct frame *frame)
+{
+ if (frame != SELECTED_FRAME ()
+ || !FRAME_EXTERNAL_MENU_BAR (frame))
+ return;
+
+ block_input ();
+ NSApplication *app = [NSApplication sharedApplication];
+ NSMenu *menu = [app mainMenu];
+ for (NSMenuItem *item in [menu itemArray])
+ {
+ if ([item hasSubmenu])
+ {
+#ifdef NS_IMPL_GNUSTEP
+ [[item submenu] display];
+#else
+ NSWindow *window = [FRAME_NS_VIEW (frame) window];
+ NSScreen *screen = [window screen];
+
+ NSRect screen_frame = [screen frame];
+ [app postEvent: [NSEvent mouseEventWithType: NSLeftMouseDown
+ location: NSMakePoint (NSMinX (screen_frame),
+ NSMinY (screen_frame) + 10)
+ modifierFlags: 0
+ timestamp: 0
+ windowNumber: [window windowNumber]
+ context: [NSGraphicsContext currentContext]
+ eventNumber: 0
+ clickCount: 1
+ pressure: 1.0f]
+ atStart: YES];
+#endif
+ break;
+ }
+ }
+ unblock_input ();
+}
/* ==========================================================================
return popup_activated () ? Qt : Qnil;
}
+DEFUN ("ns-menu-bar-open", Fns_menu_bar_open, Sns_menu_bar_open, 0, 1, "i",
+ doc: /* Start key navigation of the menu bar in FRAME.
+This initially opens the first menu bar item and you can then navigate with the
+arrow keys, select a menu entry with the return key or cancel with the
+escape key. If FRAME has no menu bar this function does nothing.
+
+If FRAME is nil or not given, use the selected frame. */)
+ (Lisp_Object frame)
+{
+ struct frame *f = decode_window_system_frame (frame);
+
+ ns_activate_menubar (f);
+
+ return Qnil;
+}
+
/* ==========================================================================
Lisp interface declaration
{
defsubr (&Sns_reset_menu);
defsubr (&Smenu_or_popup_active_p);
+ defsubr (&Sns_menu_bar_open);
DEFSYM (Qdebug_on_next_call, "debug-on-next-call");
}