Class: TkComponent::Builder::TkRadioButton

Inherits:
TkItemWithVariable show all
Defined in:
lib/tk_component/builder/tk_item.rb

Instance Attribute Summary

Attributes inherited from TkItemWithVariable

#tk_variable

Attributes inherited from TkItem

#native_item

Instance Method Summary collapse

Methods inherited from TkItemWithVariable

#apply_variable, #variable_name

Methods included from ValueTyping

#f_value, #i_value, #s_value, #update_value

Methods inherited from TkItem

#apply_internal_grid, #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 = []) ⇒ TkRadioButton

We need to use the tk_variable created by the parent_item So we set it here and skip creation below



164
165
166
167
# File 'lib/tk_component/builder/tk_item.rb', line 164

def initialize(parent_item, name, options = {}, grid = {}, event_handlers = [])
  @tk_variable = parent_item.tk_variable
  super
end

Instance Method Details

#apply_option(option, v, to_item = self.native_item) ⇒ Object

It is unfortunate that native TK radio buttons use ‘value’ to spedify the value for each of them, colliding with the ‘value’ methods for our items with variables. Thus, we need to override the setting of the ‘value’ option to revert it to the default functionality



177
178
179
180
181
182
183
184
# File 'lib/tk_component/builder/tk_item.rb', line 177

def apply_option(option, v, to_item = self.native_item)
  case option.to_sym
  when :value
    to_item.public_send(option, v)
  else
    super
  end
end

#create_variableObject



169
170
# File 'lib/tk_component/builder/tk_item.rb', line 169

def create_variable
end