Class: Glimmer::SWT::ButtonProxy

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

Constant Summary

Constants inherited from WidgetProxy

WidgetProxy::DEFAULT_INITIALIZERS

Instance Attribute Summary collapse

Attributes inherited from WidgetProxy

#args, #background, #children, #enabled, #focus, #font, #foreground, #parent, #path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from WidgetProxy

#add_css_class, #add_css_classes, #add_observer, #apply_property_type_converters, #build_dom, #can_handle_observation_request?, #clear_css_classes, #content, #css_classes, #dispose, #dom_element, for, #handle_observation_request, #has_style?, #id, #id=, #initialize, #listener_dom_element, #listener_path, max_id_number_for, max_id_numbers, #name, next_id_number_for, #parent_dom_element, #parent_path, #post_add_content, #post_initialize_child, #property_type_converters, #remove_css_class, #remove_css_classes, #render, reset_max_id_numbers!, #selector, #set_attribute, #set_focus, #style_element, underscored_widget_name, widget_class, widget_exists?, #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

Instance Attribute Details

#textObject

Returns the value of attribute text.



20
21
22
# File 'lib/glimmer/swt/button_proxy.rb', line 20

def text
  @text
end

Class Method Details

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



9
10
11
12
13
14
15
16
17
# File 'lib/glimmer/swt/button_proxy.rb', line 9

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)
  else
    new(parent, args, block)
  end
end

Instance Method Details

#domObject



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/glimmer/swt/button_proxy.rb', line 39

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

#elementObject



27
28
29
# File 'lib/glimmer/swt/button_proxy.rb', line 27

def element
  'button'
end

#observation_request_to_event_mappingObject



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

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