Class: Glimmer::SWT::ButtonProxy

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

Direct Known Subclasses

ArrowProxy

Constant Summary

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

Attributes inherited from WidgetProxy

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

Class Method Summary collapse

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 Attribute Details

#textObject

Returns the value of attribute text.



43
44
45
# File 'lib/glimmer/swt/button_proxy.rb', line 43

def text
  @text
end

Class Method Details

.create(keyword, parent, args, block) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/glimmer/swt/button_proxy.rb', line 30

def create(keyword, parent, args, block)
  if args.to_a.include?(:radio)
    RadioProxy.new(parent, args, block)
  elsif args.to_a.include?(:check)
    CheckboxProxy.new(parent, args, block)
  elsif args.to_a.include?(:arrow)
    ArrowProxy.new(parent, args, block)
  else
    new(parent, args, block)
  end
end

Instance Method Details

#domObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/glimmer/swt/button_proxy.rb', line 79

def dom
  input_text = @text
  input_id = id
  input_style = "min-width: 32px; min-height: 32px; #{css}"
  input_args = {}
  input_disabled = @enabled ? {} : {'disabled': 'disabled'}
  input_args = input_args.merge(type: 'password') if has_style?(:password)
  @dom ||= html {
    # TODO `:style` key is duplicated twice
    button(input_args.merge(id: input_id, class: name, style: input_style).merge(input_disabled)) {
      input_text.to_s == '' ? ' ' : input_text
    }
  }.to_s
end

#elementObject



55
56
57
# File 'lib/glimmer/swt/button_proxy.rb', line 55

def element
  'button'
end

#font=(value) ⇒ Object



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

def font=(value)
  super(value)
  dom_element.css('height', @font.height + 10) if @font&.height
end

#observation_request_to_event_mappingObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/glimmer/swt/button_proxy.rb', line 59

def observation_request_to_event_mapping
  myself = self
  {
    'on_widget_selected' => {
      event: 'click',
      event_handler: -> (event_listener) {
        -> (event) {
          event.define_singleton_method(:widget) {myself}
          doit = true
          event.define_singleton_method(:doit=) do |value|
            doit = value
          end
          event.define_singleton_method(:doit) { doit }
          event_listener.call(event)
        }
      }
    },
  }
end