Module: Tk::Event::Handler

Defined in:
lib/ffi-tk/event/handler.rb

Class Method Summary collapse

Class Method Details

.invoke(id, event) ⇒ Object



11
12
13
14
# File 'lib/ffi-tk/event/handler.rb', line 11

def invoke(id, event)
  return unless found = @store.at(id)
  found.call(event)
end

.register(tag, sequence, &block) ⇒ Object



27
28
29
30
31
# File 'lib/ffi-tk/event/handler.rb', line 27

def register(tag, sequence, &block)
  id = register_block(block)
  Tk.interp.eval(@callback % [tag, sequence, id, sequence])
  id
end

.register_block(block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/ffi-tk/event/handler.rb', line 16

def register_block(block)
  id = nil

  @mutex.synchronize{
    @store << block
    id = @store.size - 1
  }

  return id
end

.register_custom(block) {|id| ... } ⇒ Object

Yields:

  • (id)


33
34
35
36
37
# File 'lib/ffi-tk/event/handler.rb', line 33

def register_custom(block)
  id = register_block(block)
  yield id
  id
end

.unregister(id) ⇒ Object



39
40
41
# File 'lib/ffi-tk/event/handler.rb', line 39

def unregister(id)
  @store[id] = nil
end