Class: TT::GUI::Listbox

Inherits:
Control show all
Defined in:
TT_Lib2/gui.rb

Overview

Events

  • :change

Since:

  • 2.4.0

Instance Attribute Summary collapse

Attributes inherited from Control

#bottom, #font_bold, #font_italic, #font_name, #font_size, #height, #left, #name, #parent, #right, #tooltip, #top, #ui_id, #width, #window

Instance Method Summary collapse

Methods inherited from Control

#add_event_handler, #call_event, #disabled=, #disabled?, #enabled=, #enabled?, events, has_event?, #inspect, #move, #position, #positioned?, #properties, #release!

Methods included from ControlEvents

included

Constructor Details

#initialize(list = nil) ⇒ Listbox

Returns a new instance of Listbox

Parameters:

  • list (Array<String>) (defaults to: nil)

Since:

  • 2.5.0



694
695
696
697
698
699
700
# File 'TT_Lib2/gui.rb', line 694

def initialize( list = nil )
  super
  @value = nil
  @items = ( list.is_a?(Array) ) ? list : [] # (?) Hash instead?
  @size = nil
  @multiple = false
end

Instance Attribute Details

#itemsObject (readonly)

Since:

  • 2.5.0



686
687
688
# File 'TT_Lib2/gui.rb', line 686

def items
  @items
end

#multipleObject (readonly)

Since:

  • 2.5.0



686
687
688
# File 'TT_Lib2/gui.rb', line 686

def multiple
  @multiple
end

#sizeObject (readonly)

Since:

  • 2.5.0



686
687
688
# File 'TT_Lib2/gui.rb', line 686

def size
  @size
end

#valueString

Returns:

  • (String)

Since:

  • 2.7.0



686
687
688
# File 'TT_Lib2/gui.rb', line 686

def value
  @value
end

Instance Method Details

#add_item(string) ⇒ String #add_item(string, ...) ⇒ String

Overloads:

  • #add_item(string) ⇒ String

    Parameters:

    • string (String)
  • #add_item(string, ...) ⇒ String

    Parameters:

    • string (String)

Returns:

  • (String)

Since:

  • 2.5.0



721
722
723
724
725
726
727
728
729
730
# File 'TT_Lib2/gui.rb', line 721

def add_item( *args )
  args = args[0] if args.size == 1 && args[0].is_a?( Array )
  if args.size == 1
    @items << args[0]
    self.window.call_script( 'UI.add_list_item', self.ui_id, args[0] )
  else
    @items.concat( args )
    self.window.call_script( 'UI.add_list_item', self.ui_id, args )
  end
end

#custom_propertiesTT::JSON

Returns:

Since:

  • 2.5.0



704
705
706
707
708
709
710
711
# File 'TT_Lib2/gui.rb', line 704

def custom_properties
  prop = TT::JSON.new
  prop['value']     = @value
  prop['items']     = @items
  prop['size']      = @size if @size
  prop['multiple']  = @multiple if @multiple
  prop
end