Sha256: 3baaed091de79cd8b9b2290e1689b5153875d792e9f1c5dc76848822a858ba92

Contents?: true

Size: 1.99 KB

Versions: 7

Compression:

Stored size: 1.99 KB

Contents

module Glimmer
  module SWT
    class DisplayProxy < WidgetProxy
      class << self
        def instance
          @instance ||= new
        end
      end
      
      def initialize
        # Do not call super
      end
      
      def path
        "html body"
      end

      # Root element representing widget. Must be overridden by subclasses if different from div
      def element
        'body'
      end
      
      def listener_dom_element
        Document
      end
      
      def shells
        @shells ||= []
      end
      
      def render
        # No rendering as body is rendered as part of ShellProxy.. this class only serves as an SWT Display utility
      end
      
      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
      # sync_exec kept for API compatibility reasons
      alias sync_exec async_exec
      
      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
      
      def shells
        @shells ||= []
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
glimmer-dsl-opal-0.8.0 lib/glimmer/swt/display_proxy.rb
glimmer-dsl-opal-0.7.5 lib/glimmer/swt/display_proxy.rb
glimmer-dsl-opal-0.7.4 lib/glimmer/swt/display_proxy.rb
glimmer-dsl-opal-0.7.3 lib/glimmer/swt/display_proxy.rb
glimmer-dsl-opal-0.7.2 lib/glimmer/swt/display_proxy.rb
glimmer-dsl-opal-0.7.1 lib/glimmer/swt/display_proxy.rb
glimmer-dsl-opal-0.7.0 lib/glimmer/swt/display_proxy.rb