Class: TkComponent::Builder::TkItemWithVariable

Inherits:
TkItem
  • Object
show all
Includes:
ValueTyping
Defined in:
lib/tk_component/builder/tk_item.rb

Direct Known Subclasses

TkEntry, TkRadioButton, TkRadioSet, TkScale

Instance Attribute Summary collapse

Attributes inherited from TkItem

#native_item

Instance Method Summary collapse

Methods included from ValueTyping

#apply_option, #f_value, #i_value, #s_value, #update_value

Methods inherited from TkItem

#apply_internal_grid, #apply_option, #apply_options, #built, create, #create_native_item, #focus, #native_item_class, #remove, #set_event_handler, #set_event_handlers, #set_grid

Constructor Details

#initialize(parent_item, name, options = {}, grid = {}, event_handlers = []) ⇒ TkItemWithVariable

Returns a new instance of TkItemWithVariable.



108
109
110
111
112
# File 'lib/tk_component/builder/tk_item.rb', line 108

def initialize(parent_item, name, options = {}, grid = {}, event_handlers = [])
  create_variable
  super
  apply_variable
end

Instance Attribute Details

#tk_variableObject

Returns the value of attribute tk_variable.



106
107
108
# File 'lib/tk_component/builder/tk_item.rb', line 106

def tk_variable
  @tk_variable
end

Instance Method Details

#apply_variableObject



118
119
120
# File 'lib/tk_component/builder/tk_item.rb', line 118

def apply_variable
  self.native_item&.public_send(variable_name, @tk_variable)
end

#create_variableObject



122
123
124
# File 'lib/tk_component/builder/tk_item.rb', line 122

def create_variable
  @tk_variable = TkVariable.new
end

#variable_nameObject



114
115
116
# File 'lib/tk_component/builder/tk_item.rb', line 114

def variable_name
  :variable
end