exit fix
This commit is contained in:
@@ -160,6 +160,14 @@ module BBS
|
|||||||
end
|
end
|
||||||
|
|
||||||
def dispatch(event)
|
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
|
# Modal windows: top window gets first shot at events
|
||||||
if (win = top_window)
|
if (win = top_window)
|
||||||
result = win.handle_event(event)
|
result = win.handle_event(event)
|
||||||
@@ -171,10 +179,9 @@ module BBS
|
|||||||
return nil if result
|
return nil if result
|
||||||
end
|
end
|
||||||
|
|
||||||
# Menubar handles Alt-letter / F10 / its own keys
|
# Menubar handles Alt-letter / F10 / its own keys when closed
|
||||||
if @menubar
|
if @menubar
|
||||||
result = @menubar.handle_event(event)
|
result = @menubar.handle_event(event)
|
||||||
$stderr.puts "[app] menubar handle_event -> #{result.inspect}"
|
|
||||||
return :halt if result == :halt
|
return :halt if result == :halt
|
||||||
return nil if result
|
return nil if result
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -120,9 +120,7 @@ module BBS
|
|||||||
when :escape, :f10
|
when :escape, :f10
|
||||||
close
|
close
|
||||||
when :enter
|
when :enter
|
||||||
r = activate_current
|
return activate_current
|
||||||
$stderr.puts "[menu] navigate enter -> #{r.inspect}"
|
|
||||||
return r
|
|
||||||
else
|
else
|
||||||
if event.char?
|
if event.char?
|
||||||
activated = activate_by_hotkey(menu.items, event.key)
|
activated = activate_by_hotkey(menu.items, event.key)
|
||||||
@@ -194,7 +192,6 @@ module BBS
|
|||||||
return :handled unless item && !item.separator && item.enabled != false
|
return :handled unless item && !item.separator && item.enabled != false
|
||||||
close
|
close
|
||||||
result = item.on_select&.call(item)
|
result = item.on_select&.call(item)
|
||||||
$stderr.puts "[menu] activate_current item=#{item.label.inspect} result=#{result.inspect}"
|
|
||||||
@on_activate&.call(item)
|
@on_activate&.call(item)
|
||||||
result == :halt ? :halt : :handled
|
result == :halt ? :halt : :handled
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user