Class: PPCurses::Responder

Inherits:
Object
  • Object
show all
Defined in:
lib/ppcurses/application.rb

Overview

Direct Known Subclasses

MenuBar, ResponderManager

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#next_responderObject

Returns the value of attribute next_responder.



11
12
13
# File 'lib/ppcurses/application.rb', line 11

def next_responder
  @next_responder
end

Class Method Details

.isa(obj) ⇒ Object



55
56
57
# File 'lib/ppcurses/application.rb', line 55

def Responder.isa( obj )
  PPCurses.implements_protocol( obj, %w(accepts_first_responder become_first_responder resign_first_responder key_down))
end

Instance Method Details

#accepts_first_responderObject

Whether the responder accepts first responder status.

As first responder, the receiver is the first object in the responder chain to be sent key events and action messages. By default, this property is NO. Subclasses set this property to YES if the receiver accepts first responder status.



20
21
22
# File 'lib/ppcurses/application.rb', line 20

def accepts_first_responder
  NO
end

#become_first_responderObject

Notifies the receiver that it’s about to become first responder

The default implementation returns YES, accepting first responder status. Subclasses can override this method to update state or perform some action such as highlighting the selection, or to return NO, refusing first responder status.



31
32
33
# File 'lib/ppcurses/application.rb', line 31

def become_first_responder
  YES
end

#key_down(key) ⇒ Object

Informs the receiver that the user has pressed a key.

The default implementation simply passes this message to the next responder.



51
52
53
# File 'lib/ppcurses/application.rb', line 51

def key_down( key )
  @next_responder.key_down(key) unless @next_responder.nil?
end

#resign_first_responderObject

Notifies the receiver that it’s been asked to relinquish its status as first responder in its window.

The default implementation returns YES, resigning first responder status. Subclasses can override this method to update state or perform some action such as unhighlighting the selection, or to return NO, refusing to relinquish first responder status.



42
43
44
# File 'lib/ppcurses/application.rb', line 42

def resign_first_responder
  YES
end