Class: RatatuiRuby::Event::FocusGained
- Inherits:
-
RatatuiRuby::Event
- Object
- RatatuiRuby::Event
- RatatuiRuby::Event::FocusGained
- Defined in:
- lib/ratatui_ruby/event/focus_gained.rb
Overview
Signals that the application is now active.
The user interacts with many windows. Your application needs to know when it has their attention.
This event confirms visibility. It fires when the terminal window moves to the foreground.
Use it to resume paused activities. Restart animations. Refresh data. The user is watching.
Only supported by some terminals (e.g. iTerm2, Kitty, newer xterm).
Example
– SPDX-SnippetBegin SPDX-FileCopyrightText: 2025 Kerrick Long SPDX-License-Identifier: MIT-0 ++
if event.focus_gained?
puts "Focus gained"
end
– SPDX-SnippetEnd ++
Instance Method Summary collapse
-
#==(other) ⇒ Object
Compares this event with another for equality.
-
#active? ⇒ Boolean
(also: #foreground?)
Returns true.
-
#blur? ⇒ Boolean
(also: #blurred?)
Returns false.
-
#deconstruct_keys(keys) ⇒ Object
Deconstructs the event for pattern matching.
-
#focus? ⇒ Boolean
(also: #focused?)
Returns true.
-
#focus_gained? ⇒ Boolean
Returns true for FocusGained events.
-
#gained? ⇒ Boolean
Returns true.
-
#inactive? ⇒ Boolean
(also: #background?)
Returns false.
-
#lost? ⇒ Boolean
Returns false.
Methods inherited from RatatuiRuby::Event
#focus_lost?, #key?, #method_missing, #mouse?, #none?, #paste?, #resize?, #respond_to_missing?, #sync?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RatatuiRuby::Event
Instance Method Details
#==(other) ⇒ Object
Compares this event with another for equality.
70 71 72 |
# File 'lib/ratatui_ruby/event/focus_gained.rb', line 70 def ==(other) other.is_a?(FocusGained) end |
#active? ⇒ Boolean Also known as: foreground?
Returns true. The application is active.
event.active? # => true
111 112 113 |
# File 'lib/ratatui_ruby/event/focus_gained.rb', line 111 def active? true end |
#blur? ⇒ Boolean Also known as: blurred?
Returns false. Blur is the opposite of focus gained.
event.blur? # => false
103 104 105 |
# File 'lib/ratatui_ruby/event/focus_gained.rb', line 103 def blur? false end |
#deconstruct_keys(keys) ⇒ Object
Deconstructs the event for pattern matching.
– SPDX-SnippetBegin SPDX-FileCopyrightText: 2025 Kerrick Long SPDX-License-Identifier: MIT-0 ++
case event
in type: :focus_gained
puts "Application gained focus"
end
– SPDX-SnippetEnd ++
64 65 66 |
# File 'lib/ratatui_ruby/event/focus_gained.rb', line 64 def deconstruct_keys(keys) { type: :focus_gained } end |
#focus? ⇒ Boolean Also known as: focused?
Returns true. The terminal window is now in focus.
event.focus? # => true
81 82 83 |
# File 'lib/ratatui_ruby/event/focus_gained.rb', line 81 def focus? true end |
#focus_gained? ⇒ Boolean
Returns true for FocusGained events.
– SPDX-SnippetBegin SPDX-FileCopyrightText: 2025 Kerrick Long SPDX-License-Identifier: MIT-0 ++
event.focus_gained? # => true
event.key? # => false
– SPDX-SnippetEnd ++
46 47 48 |
# File 'lib/ratatui_ruby/event/focus_gained.rb', line 46 def focus_gained? true end |
#gained? ⇒ Boolean
Returns true. The application gained focus.
event.gained? # => true
89 90 91 |
# File 'lib/ratatui_ruby/event/focus_gained.rb', line 89 def gained? true end |
#inactive? ⇒ Boolean Also known as: background?
Returns false. The application is not inactive.
event.inactive? # => false
119 120 121 |
# File 'lib/ratatui_ruby/event/focus_gained.rb', line 119 def inactive? false end |
#lost? ⇒ Boolean
Returns false. This is not a focus lost event.
event.lost? # => false
96 97 98 |
# File 'lib/ratatui_ruby/event/focus_gained.rb', line 96 def lost? false end |