Class: Teek::UI::EventBinding

Inherits:
Data
  • Object
show all
Defined in:
lib/teek/ui/event_binding.rb

Overview

An event a node wants wired up. target is nil to bind on the node's own widget, or a Symbol naming another node's widget - resolved by the realizer's link pass, after every node in the whole tree has already been created, so a target declared later in the build still resolves correctly (the forward-reference case). subs are App#bind substitution codes (e.g. %i[x y]) forwarded to the handler when it fires.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event:, handler:, target: nil, subs: []) ⇒ EventBinding

Returns a new instance of EventBinding.

Parameters:

  • event (String)

    a Tk bind event pattern, e.g. "<Button-1>"

  • handler (#call)

    called with whatever subs substitutes

  • target (Symbol, nil) (defaults to: nil)

    another node's name, or nil for self

  • subs (Array<Symbol, String>) (defaults to: [])

    see App#bind



17
18
19
# File 'lib/teek/ui/event_binding.rb', line 17

def initialize(event:, handler:, target: nil, subs: [])
  super
end

Instance Attribute Details

#eventObject (readonly)

Returns the value of attribute event

Returns:

  • (Object)

    the current value of event



12
13
14
# File 'lib/teek/ui/event_binding.rb', line 12

def event
  @event
end

#handlerObject (readonly)

Returns the value of attribute handler

Returns:

  • (Object)

    the current value of handler



12
13
14
# File 'lib/teek/ui/event_binding.rb', line 12

def handler
  @handler
end

#subsObject (readonly)

Returns the value of attribute subs

Returns:

  • (Object)

    the current value of subs



12
13
14
# File 'lib/teek/ui/event_binding.rb', line 12

def subs
  @subs
end

#targetObject (readonly)

Returns the value of attribute target

Returns:

  • (Object)

    the current value of target



12
13
14
# File 'lib/teek/ui/event_binding.rb', line 12

def target
  @target
end