Class: Glimmer::SWT::CheckboxProxy
- Inherits:
-
WidgetProxy
- Object
- WidgetProxy
- Glimmer::SWT::CheckboxProxy
- Defined in:
- lib/glimmer/swt/checkbox_proxy.rb
Constant Summary collapse
- STYLE =
TODO add a create method that ensures passing :check style in if not there
<<~CSS .checkbox { display: inline; } .checkbox-label { display: inline; } 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 collapse
-
#text ⇒ Object
TODO consider reuse of logic in Radioproxy.
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
- #dom ⇒ Object
- #element ⇒ Object
- #label_class ⇒ Object
- #label_dom_element ⇒ Object
- #label_id ⇒ Object
- #observation_request_to_event_mapping ⇒ Object
- #selection ⇒ Object
- #selection=(value) ⇒ Object
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 Attribute Details
#text ⇒ Object
TODO consider reuse of logic in Radioproxy
16 17 18 |
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 16 def text @text end |
Instance Method Details
#dom ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 57 def dom check_text = @text check_id = id check_style = "min-width: 27px; #{css}" check_class = name check_selection = @selection # TODO `:style` key is duplicated twice = {type: 'checkbox', id: check_id, name: parent.id, style: check_style, class: check_class, value: check_text} [checked: 'checked'] if check_selection @dom ||= html { span { input() { } label(id: label_id, class: label_class, for: check_id) { check_text } } }.to_s end |
#element ⇒ Object
33 34 35 |
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 33 def element 'input' end |
#label_class ⇒ Object
49 50 51 |
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 49 def label_class "#{name}-label" end |
#label_dom_element ⇒ Object
53 54 55 |
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 53 def label_dom_element Element.find("##{label_id}") end |
#label_id ⇒ Object
45 46 47 |
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 45 def label_id "#{id}-label" end |
#observation_request_to_event_mapping ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 37 def observation_request_to_event_mapping { 'on_widget_selected' => { event: 'change' }, } end |
#selection ⇒ Object
24 25 26 |
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 24 def selection dom_element.prop('checked') end |
#selection=(value) ⇒ Object
28 29 30 31 |
# File 'lib/glimmer/swt/checkbox_proxy.rb', line 28 def selection=(value) @selection = value dom_element.prop('checked', @selection) end |