abstract class TUI::Widget
- TUI::Widget
- Reference
- Object
Direct Known Subclasses
- TUI::Widget::Main
- TUI::Widget::Menu
- TUI::Widget::MenuItem
- TUI::Widget::Modal
- TUI::Widget::ModalHolder
- TUI::Widget::Stacked
- TUI::Widget::TextEditor
Defined in:
tui/widget.crConstructors
Instance Method Summary
- #<<(win : Widget)
- #app : Application
- #app=(app : Application | Nil)
- #bind(key : Key | Char, &block : Event::Key -> Bool) : self
- #bind(mouse : MouseStatus, &block : Event::Mouse -> Bool) : self
- #border : Border
- #border=(border : Border | Nil)
- #dirty : Bool
- #dirty=(v : Bool)
- #dirty? : Bool
- #dump_tree_rect(io : IO, e : Event::Mouse, far = 0)
- #focused : Bool
- #focused=(focused : Bool)
- #h(*args, **options)
- #h(*args, **options, &)
- #handle(event : Event::Resize) : Bool
- #handle(event : Event::Draw) : Bool
-
#handle(event : Event::Key) : Bool
Handle an event:
-
#handle(event : Event::Mouse) : Bool
ditto
- #height(w : Int32) : Int32 | Nil
- #height : Int32 | Nil
- #hover : Tuple(Int32, Int32) | Nil
- #hover=(hover : Tuple(Int32, Int32) | Nil)
-
#key(event : Event::Key) : Bool
Overwrite to handle other unknown key presses
- #layout : Layout
- #layout=(layout : Layout | Nil)
-
#mouse(event : Event::Mouse) : Bool
Overwrite to handle other unknown mouse events
-
#paint(surface : Painter) : Bool
Override to draw in the widget
- #parent : Widget | Nil
- #parent! : Widget
- #parent=(new_parent : TUI::Widget | Nil)
- #rect : Rect
- #rect=(rect : Rect)
- #rect? : Rect | Nil
- #set_focused(val : Bool)
- #set_hover(e : Event::Mouse)
- #set_hover(xy : Tuple(Int32, Int32) | Nil)
- #tree_focused? : Bool
- #unbind(key : Key | Char) : self
- #unbind(mouse : MouseStatus) : self
- #unbind_all : self
- #unbind_keys : self
- #unbind_mouse : self
- #w(*args, **options)
- #w(*args, **options, &)
- #width(h : Int32) : Int32 | Nil
- #width : Int32 | Nil
- #x(*args, **options)
- #x(*args, **options, &)
- #y(*args, **options)
- #y(*args, **options, &)
Constructor Detail
Instance Method Detail
def handle(event : Event::Key) : Bool
#
Handle an event:
- Firstly see if it has been bound
- Secondly pass to the overwritable key method
- Then pass to the parent recursively
When there are no parent, false is returned and the event is left unhandled