class PPCurses::ResponderManager

Derived from methods defined in Cocoa NSWindow

Current link, which probably won't be valid in the future ...

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/index.html#//apple_ref/occ/instm/NSWindow

Attributes

first_responder[RW]

The first responder is the first object in a responder chain to receive an event or action message.

Public Instance Methods

accepts_first_responder() click to toggle source
# File lib/ppcurses/application.rb, line 74
def accepts_first_responder
  YES
end
make_first_responder( responder ) click to toggle source

Attempts to make a given responder the first responder

If responder isn’t already the first responder, this method first sends a resign_first_responder message to the object that is the first responder. If that object refuses to resign, it remains the first responder, and this method immediately returns NO. If the current first responder resigns, this method sends a become_first_responder message to responder.

If responder does not accept first responder status, the ResponderManager becomes first responder; in this case, the method returns YES even if the responder refused first responder status.

If responder is nil, this method still sends resign_first_responder to the current first responder.

# File lib/ppcurses/application.rb, line 92
def make_first_responder( responder )

  Responder.isa(responder) unless responder.nil?

  if responder != @first_responder
    will_resign = responder.resign_first_responder
    unless will_resign
      return NO
    end
  end

  @first_responder = nil

  accepted = NO
  will_accept = responder.accepts_first_responder

  if will_accept
    accepted = responder.become_first_responder
  end

  unless accepted
    @first_responder = self
    return YES
  end

  @first_responder = responder

  YES
end