Class: Glimmer::SWT::DisplayProxy

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

Constant Summary

Constants inherited from WidgetProxy

WidgetProxy::DEFAULT_INITIALIZERS

Instance Attribute Summary

Attributes inherited from WidgetProxy

#args, #background, #children, #disposed?, #enabled, #focus, #font, #foreground, #menu, #menu_requested, #parent, #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, #build_dom, #can_handle_observation_request?, #clear_css_classes, #content, #content_on_render_blocks, #css_classes, #default_observation_request_to_event_mapping, #dispose, #dom_element, #effective_observation_request_to_event_mapping, #event_listener_proxies, for, #get_data, #handle_observation_request, #has_style?, #id, #id=, #layout, #listener_path, max_id_number_for, max_id_numbers, #method_missing, #name, next_id_number_for, #observation_requests, #pack, #parent_dom_element, #parent_path, #post_add_content, #post_dispose_child, #post_initialize_child, #property_type_converters, #remove_all_listeners, #remove_css_class, #remove_css_classes, #remove_event_listener_proxies, reset_max_id_numbers!, #selector, #set_attribute, #set_data, #set_focus, #skip_content_on_render_blocks?, #style_element, #swt_widget, 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

#initializeDisplayProxy

Returns a new instance of DisplayProxy.



10
11
12
# File 'lib/glimmer/swt/display_proxy.rb', line 10

def initialize
  # Do not call super
end

Dynamic Method Handling

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

Class Method Details

.instanceObject



5
6
7
# File 'lib/glimmer/swt/display_proxy.rb', line 5

def instance
  @instance ||= new
end

Instance Method Details

#async_exec(&block) ⇒ Object Also known as: sync_exec



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

def async_exec(&block)
  executer = lambda do
    if Document.find('.modal').to_a.empty?
      block.call
    else
      sleep(0.05)
      Async::Task.new(&executer)
    end
  end
  Async::Task.new(&executer)
end

#elementObject

Root element representing widget. Must be overridden by subclasses if different from div



19
20
21
# File 'lib/glimmer/swt/display_proxy.rb', line 19

def element
  'body'
end

#listener_dom_elementObject



23
24
25
# File 'lib/glimmer/swt/display_proxy.rb', line 23

def listener_dom_element
  Document
end

#message_boxesObject



31
32
33
# File 'lib/glimmer/swt/display_proxy.rb', line 31

def message_boxes
  @message_boxes ||= []
end

#observation_request_to_event_mappingObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/glimmer/swt/display_proxy.rb', line 53

def observation_request_to_event_mapping
  {
    'on_swt_keydown' => [
      {
        event: 'keypress',
        event_handler: -> (event_listener) {
          -> (event) {
            event.singleton_class.define_method(:character) do
              which || key_code
            end
            event_listener.call(event)
          }
        }
      },
      {
        event: 'keydown',
        event_handler: -> (event_listener) {
          -> (event) {
            event.singleton_class.define_method(:character) do
              which || key_code
            end
            event_listener.call(event) if event.key_code != 13 && (event.key_code == 127 || event.key_code <= 31)
          }
        }
      }
    ]
  }
end

#pathObject



14
15
16
# File 'lib/glimmer/swt/display_proxy.rb', line 14

def path
  "html body"
end

#renderObject



35
36
37
# File 'lib/glimmer/swt/display_proxy.rb', line 35

def render
  # No rendering as body is rendered as part of ShellProxy.. this class only serves as an SWT Display utility
end

#shellsObject



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

def shells
  @shells ||= []
end