first responder when there is no responder chain

  • Hi,

    I'm trying to use NSFontManager/NSFontPanel from within a Carbon app.
    Naturally, there is no NSApplication/NSWindow or similar instantiated, so
    I don't have any instance of an NSResponder anywhere. NSFontManater's
    (void)changeFont:(id)sender however is being sent to the first responder.
    Is there a method of catching the changeFont: message without having to
    open a NSWindow?

    thanks,
    Stefan
  • Stefan,

    With Leopard and later, you can redirect the action message using -
    [NSFontManager setTarget:].
    For Tiger, you should be able to receive the action message as
    NSApplication delegate.

    > Naturally, there is no NSApplication/NSWindow or similar
    > instantiated, so I don't have any instance of an NSResponder anywhere.
    You're required to call NSApplicationLoad() before accessing any Cocoa
    objects from Carbon applications.

    The function initializes NSApp.

    Aki

    On 2007/11/08, at 14:28, Stefan Werner wrote:

    > Hi,
    >
    > I'm trying to use NSFontManager/NSFontPanel from within a Carbon
    > app. Naturally, there is no NSApplication/NSWindow or similar
    > instantiated, so I don't have any instance of an NSResponder
    > anywhere. NSFontManater's (void)changeFont:(id)sender however is
    > being sent to the first responder. Is there a method of catching the
    > changeFont: message without having to open a NSWindow?
    >
    > thanks,
    > Stefan
  • On Thu, 08 Nov 2007 23:55:13 +0100, Aki Inoue <aki...> wrote:

    > With Leopard and later, you can redirect the action message using -
    > [NSFontManager setTarget:].
    > For Tiger, you should be able to receive the action message as
    > NSApplication delegate.

    Thanks. That works beautifully. I was trying to make my class the delegate
    of NSFontManager, but that didn't work.

    >> Naturally, there is no NSApplication/NSWindow or similar instantiated,
    >> so I don't have any instance of an NSResponder anywhere.
    > You're required to call NSApplicationLoad() before accessing any Cocoa
    > objects from Carbon applications.
    >
    > The function initializes NSApp.

    Good to know. I wasn't sure how comparable a NSApplicationLoad()
    initialized NSApplication is to one created during the startup of a Cocoa
    app.

    Thanks for the quick help,
    Stefan
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today