Sha256: 2f8fd91387223989a6a315672a68461063b192e3600ae1da0283765a39efedc2
Contents?: true
Size: 903 Bytes
Versions: 4
Compression:
Stored size: 903 Bytes
Contents
module Nuklear module UI class SelectList < Nuklear::UI::Base include Nuklear::UI::Container attr_accessor :choices, :selection, :item_height, :width, :height def initialize(choices, selection: choices[0], item_height:, width:, height:, **options) super(**options) self.choices = choices self.selection = selection self.item_height = item_height self.width = width self.height = height on(:selection_changed) { yield self.selection } if block_given? end def to_command [ :ui_combo, choices.index(selection) || 0, choices, item_height, width, height ] end def result(choice_index, context) if @selection != choices[choice_index] @selection = choices[choice_index] trigger(:selection_changed) @last_event = nil end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
nuklear-0.1.3 | lib/nuklear/ui/select_list.rb |
nuklear-0.1.2 | lib/nuklear/ui/select_list.rb |
nuklear-0.1.1 | lib/nuklear/ui/select_list.rb |
nuklear-0.1.0 | lib/nuklear/ui/select_list.rb |