Sha256: 38aea1ac4c4961b9cdf04336980b3effc6c57893240a231e814b7195fec7f829
Contents?: true
Size: 1007 Bytes
Versions: 1
Compression:
Stored size: 1007 Bytes
Contents
module TerminalNotes class SearchField < Widget WIDTH = 0.5 HEIGHT = 5 POS_X = 0 POS_Y = 1 ALIGN = :center def initialize(parent:) super(parent: parent, title: "Search", width: WIDTH, height: HEIGHT, x: POS_X, y: POS_Y, align: ALIGN) @text_field = TextField.new(@parent, position: @position.dup.moveBy(2, 2), width: @width - 4) @has_focus = false draw end def text @text_field.text end def focus @has_focus = true @text_field.draw end def unfocus @has_focus = false end def on_text_changed &delegate @text_field.on_text_changed { |p| delegate.call(p) } end def on_key key return unless @has_focus @text_field.on_key(key) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
terminal-notes-0.0.1 | lib/terminal-notes/search_field.rb |