diff --git a/lib/bbs/application.rb b/lib/bbs/application.rb index 8fbdc55..2f37c00 100644 --- a/lib/bbs/application.rb +++ b/lib/bbs/application.rb @@ -160,6 +160,14 @@ module BBS end def dispatch(event) + # An open menubar has priority — its keys (arrows, Enter, hotkeys, Esc) + # must beat any modal window's focused widget. + if @menubar&.open? + result = @menubar.handle_event(event) + return :halt if result == :halt + return nil if result + end + # Modal windows: top window gets first shot at events if (win = top_window) result = win.handle_event(event) @@ -171,10 +179,9 @@ module BBS return nil if result end - # Menubar handles Alt-letter / F10 / its own keys + # Menubar handles Alt-letter / F10 / its own keys when closed if @menubar result = @menubar.handle_event(event) - $stderr.puts "[app] menubar handle_event -> #{result.inspect}" return :halt if result == :halt return nil if result end diff --git a/lib/bbs/menu.rb b/lib/bbs/menu.rb index b8c8a38..3371613 100644 --- a/lib/bbs/menu.rb +++ b/lib/bbs/menu.rb @@ -120,9 +120,7 @@ module BBS when :escape, :f10 close when :enter - r = activate_current - $stderr.puts "[menu] navigate enter -> #{r.inspect}" - return r + return activate_current else if event.char? activated = activate_by_hotkey(menu.items, event.key) @@ -194,7 +192,6 @@ module BBS return :handled unless item && !item.separator && item.enabled != false close result = item.on_select&.call(item) - $stderr.puts "[menu] activate_current item=#{item.label.inspect} result=#{result.inspect}" @on_activate&.call(item) result == :halt ? :halt : :handled end