Class: Glimmer::SWT::RadioProxy

Inherits:
WidgetProxy show all
Defined in:
lib/glimmer/swt/radio_proxy.rb

Constant Summary collapse

STYLE =

TODO add a create method that ensures passing :radio style in if not there

<<~CSS
  .radio {
    display: inline;
  }
  .radio-label {
    display: inline;
  }
  .radio-container {
  }
CSS

Constants inherited from WidgetProxy

WidgetProxy::DEFAULT_INITIALIZERS, WidgetProxy::JS_KEY_CODE_TO_SWT_KEY_CODE_MAP, WidgetProxy::JS_LOCATION_TO_SWT_KEY_LOCATION_MAP, WidgetProxy::SWT_CURSOR_TO_CSS_CURSOR_MAP

Instance Attribute Summary

Attributes inherited from WidgetProxy

#args, #background, #children, #cursor, #disposed?, #enabled, #focus, #font, #foreground, #menu, #menu_requested, #menu_x, #menu_y, #parent, #path, #rendered

Instance Method Summary collapse

Methods inherited from WidgetProxy

#add_content_on_render, #add_css_class, #add_css_classes, #add_observer, #apply_property_type_converters, #attach, #build_dom, #can_handle_observation_request?, #clear_css_classes, #content, #content_on_render_blocks, #css_classes, #default_observation_request_to_event_mapping, #dialog_ancestor, #dispose, #dom_element, #effective_observation_request_to_event_mapping, #event_handling_suspended?, #event_listener_proxies, for, #get_data, #handle_javascript_observation_request, #handle_observation_request, #has_style?, #id, #id=, #initialize, #listener_dom_element, #listener_path, #listeners, #listeners_for, max_id_number_for, max_id_numbers, #method_missing, #name, next_id_number_for, #observation_requests, #parent_dom_element, #parent_path, #parents, #post_add_content, #post_dispose_child, #post_initialize_child, #print, #property_type_converters, #reattach, #remove_all_listeners, #remove_css_class, #remove_css_classes, #remove_event_listener_proxies, #render, reset_max_id_numbers!, #resume_event_handling, #selector, #set_attribute, #set_data, #set_focus, #shell, #skip_content_on_render_blocks?, #style_element, #suspend_event_handling, #swt_data, #swt_widget, underscored_widget_name, widget_class, widget_exists?, widget_handling_listener, #widget_property_listener_installers

Methods included from PropertyOwner

#attribute_getter, #attribute_setter, #get_attribute, #set_attribute

Constructor Details

This class inherits a constructor from Glimmer::SWT::WidgetProxy

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Glimmer::SWT::WidgetProxy

Instance Method Details

#container_idObject



54
55
56
# File 'lib/glimmer/swt/radio_proxy.rb', line 54

def container_id
  "#{id}-container"
end

#container_nameObject



58
59
60
# File 'lib/glimmer/swt/radio_proxy.rb', line 58

def container_name
  "#{name}-container"
end

#domObject



70
71
72
73
74
75
76
77
78
79
# File 'lib/glimmer/swt/radio_proxy.rb', line 70

def dom
  @dom ||= html {
    span(id: container_id, class: container_name) {
      input(type: 'radio', id: id, class: name, name: parent&.id)
      label(id: label_id, class: label_name, for: id) {
        text
      }
    }
  }.to_s
end

#elementObject



34
35
36
# File 'lib/glimmer/swt/radio_proxy.rb', line 34

def element
  'input'
end

#label_dom_elementObject



50
51
52
# File 'lib/glimmer/swt/radio_proxy.rb', line 50

def label_dom_element
  Document.find(label_path)
end

#label_idObject



38
39
40
# File 'lib/glimmer/swt/radio_proxy.rb', line 38

def label_id
  "#{id}-label"
end

#label_nameObject



42
43
44
# File 'lib/glimmer/swt/radio_proxy.rb', line 42

def label_name
  "#{name}-label"
end

#label_pathObject



46
47
48
# File 'lib/glimmer/swt/radio_proxy.rb', line 46

def label_path
  "#{parent_path} ##{label_id}"
end

#observation_request_to_event_mappingObject



62
63
64
65
66
67
68
# File 'lib/glimmer/swt/radio_proxy.rb', line 62

def observation_request_to_event_mapping
  {
    'on_widget_selected' => {
      event: 'change'
    },
  }
end

#selectionObject



26
27
28
# File 'lib/glimmer/swt/radio_proxy.rb', line 26

def selection
  dom_element.prop('checked')
end

#selection=(value) ⇒ Object



30
31
32
# File 'lib/glimmer/swt/radio_proxy.rb', line 30

def selection=(value)
  dom_element.prop('checked', value)
end

#textObject



18
19
20
# File 'lib/glimmer/swt/radio_proxy.rb', line 18

def text
  label_dom_element.html
end

#text=(value) ⇒ Object



22
23
24
# File 'lib/glimmer/swt/radio_proxy.rb', line 22

def text=(value)
  label_dom_element.html(value)
end