Archived
1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
cli-old/lib/widgets/window.rb
Braiden Vasco 237bc43aab Fix style
2017-07-22 18:21:16 +00:00

30 lines
593 B
Ruby

# frozen_string_literal: true
module Widgets
class Window < Container
def initialize(x, y, width, height)
super
@menu = Widgets::Menu.new 0, 0, nil, height
@messenger = Widgets::Messenger.new 0, 0, width - @menu.width, height
self.focus = @messenger
@menu_visible = false
end
def children
focus == @menu ? [@messenger, @menu] : [@messenger]
end
def trigger(event)
case event
when Events::Tab
self.focus = focus == @menu ? @messenger : @menu
else
focus.trigger event
end
end
end
end