int zoomed_p = 0;
int shown_flag = 0;
volatile int was_shown_p = 0;
+ bool menu_bar_active_p = false;
EmacsWindow () : BWindow (BRect (0, 0, 0, 0), "", B_TITLED_WINDOW_LOOK,
B_NORMAL_WINDOW_FEEL, B_NO_SERVER_SIDE_WINDOW_MODIFIERS)
if (msg->what == B_KEY_DOWN || msg->what == B_KEY_UP)
{
struct haiku_key_event rq;
+
+ /* Pass through key events to the regular dispatch mechanism
+ if the menu bar active, so that key navigation can work. */
+ if (menu_bar_active_p)
+ {
+ BWindow::DispatchMessage (msg, handler);
+ return;
+ }
+
rq.window = this;
int32_t code = msg->GetInt32 ("raw_char", 0);
rq.window = this;
haiku_write (MENU_BAR_OPEN, &rq);
+ menu_bar_active_p = true;
}
void
rq.window = this;
haiku_write (MENU_BAR_CLOSE, &rq);
+ menu_bar_active_p = false;
}
void
{
}
+ void
+ AttachedToWindow (void)
+ {
+ BWindow *window = Window ();
+
+ window->SetKeyMenuBar (this);
+ }
+
void
FrameResized (float newWidth, float newHeight)
{
{
BView *vw = (BView *) menubar;
BView *p = vw->Parent ();
+ EmacsWindow *window = (EmacsWindow *) p->Window ();
+
if (!p->LockLooper ())
gui_abort ("Failed to lock menu bar parent while removing menubar");
+ window->SetKeyMenuBar (NULL);
+ /* MenusEnded isn't called if the menu bar is destroyed
+ before it closes. */
+ window->menu_bar_active_p = false;
vw->RemoveSelf ();
p->UnlockLooper ();
delete vw;
}
DEFUN ("haiku-menu-bar-open", Fhaiku_menu_bar_open, Shaiku_menu_bar_open, 0, 1, "i",
- doc: /* Show the menu bar in FRAME.
-
-Move the mouse pointer onto the first element of FRAME's menu bar, and
-cause it to be opened. If FRAME is nil or not given, use the selected
-frame. If FRAME has no menu bar, a pop-up is displayed at the position
-of the last non-menu event instead. */)
+ doc: /* Show and 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 is nil or not given, use the
+selected frame. If FRAME has no menu bar, a pop-up is displayed at
+the position of the last non-menu event instead. */)
(Lisp_Object frame)
{
struct frame *f = decode_window_system_frame (frame);