Class: Swt::EventLoop

Inherits:
Object
  • Object
show all
Defined in:
lib/swt/event_loop.rb

Instance Method Summary collapse

Constructor Details

#initializeEventLoop

Returns a new instance of EventLoop.



4
5
6
# File 'lib/swt/event_loop.rb', line 4

def initialize
  @running = false
end

Instance Method Details

#startObject

Begins the SWT event loop. Blocks.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/swt/event_loop.rb', line 9

def start
  @running = true
  @display = Swt.display
  while @running and not @display.disposed?
    begin
      unless read = @display.read_and_dispatch
        @display.sleep
      end
    rescue java.lang.Throwable => e
      puts "Error in Event Loop:"
      p e
      puts e.backtrace
    end
  end
  @display.dispose
end

#stopObject

Halts the SWT event loop.



32
33
34
# File 'lib/swt/event_loop.rb', line 32

def stop
  @running = false
end

#yield_untilObject

Lets the even loop run until block returns false



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

def yield_until
  @display.read_and_dispatch until yield
end