Module: WindowBlessing::Window::KeyboardFocus

Included in:
WindowBlessing::Window
Defined in:
lib/window_blessing/window.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#focusedObject (readonly)

keyboard focusing



60
61
62
# File 'lib/window_blessing/window.rb', line 60

def focused
  @focused
end

#focused_childObject

keyboard focusing



60
61
62
# File 'lib/window_blessing/window.rb', line 60

def focused_child
  @focused_child
end

Instance Method Details

#blurObject



80
81
82
83
84
85
86
87
88
89
# File 'lib/window_blessing/window.rb', line 80

def blur
  return if blurred?
  if focused_child
    focused_child.blur
    @focused_child = nil
  end

  @focused = false
  handle_event :type => :blur
end

#blurred?Boolean

Returns:

  • (Boolean)


91
# File 'lib/window_blessing/window.rb', line 91

def blurred?; !@focused end

#focusObject



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/window_blessing/window.rb', line 67

def focus
  return if focused?
  if parent
    parent.focus
    parent_focused_child = parent.focused_child
    parent_focused_child.blur if parent_focused_child
    parent.focused_child = self
  end

  @focused = true
  handle_event :type => :focus
end

#focused?Boolean

Returns:

  • (Boolean)


92
# File 'lib/window_blessing/window.rb', line 92

def focused?; !!@focused end

#route_keyboard_event(event) ⇒ Object



94
95
96
97
98
99
# File 'lib/window_blessing/window.rb', line 94

def route_keyboard_event(event)
  if focused_child
    focused_child.route_keyboard_event event
  end
  handle_event event
end