NSRunAlertPanel is not responding to Enter

  • Hello:

    I have an NSRunAlertPanel which pops up a simple dialog box with an OK
    button.  Normally, just pressing the Enter/Return button will tell the
    window to disappear.

    However, I've hit a snag where I'm finding this isn't working now.
    But I believe I've discovered the source of the problems.  I'm
    overriding the keyDown for NSWindow so I can catch when certain keys
    are getting pressed.  I'm also finding that when I'm hitting Enter, my
    keyDown method is grabbing this event.  I've tried telling the program
    to send to the next registered handler, but it doesn't seem to change
    anything.

    Is there a way that I can set my NSRunAlertPanel so when I hit Enter
    it will go away?  (If I just click on the OK button, it goes away with
    no problems.)

    Regards,

    Chad Armstrong
  • On Jan 16, 2008, at 8:57 PM, Chad Armstrong wrote:

    > However, I've hit a snag where I'm finding this isn't working now.
    > But I believe I've discovered the source of the problems.  I'm
    > overriding the keyDown for NSWindow so I can catch when certain keys
    > are getting pressed.  I'm also finding that when I'm hitting Enter,
    > my keyDown method is grabbing this event.  I've tried telling the
    > program to send to the next registered handler, but it doesn't seem
    > to change anything.

    I think if you respond to the key event, the responder search will
    stop. You should be able to forward it on, though. What does your
    forwarding code look like?

          - Scott
  • Sounds like really bad practice to override a key feature in a
    generic superclass. You should do your override in a subclass. And
    otherwise use [super keyDown:].

    Christiaan

    On 17 Jan 2008, at 5:57 AM, Chad Armstrong wrote:

    > Hello:
    >
    > I have an NSRunAlertPanel which pops up a simple dialog box with an
    > OK button.  Normally, just pressing the Enter/Return button will
    > tell the window to disappear.
    >
    > However, I've hit a snag where I'm finding this isn't working now.
    > But I believe I've discovered the source of the problems.  I'm
    > overriding the keyDown for NSWindow so I can catch when certain
    > keys are getting pressed.  I'm also finding that when I'm hitting
    > Enter, my keyDown method is grabbing this event.  I've tried
    > telling the program to send to the next registered handler, but it
    > doesn't seem to change anything.
    >
    > Is there a way that I can set my NSRunAlertPanel so when I hit
    > Enter it will go away?  (If I just click on the OK button, it goes
    > away with no problems.)
    >
    > Regards,
    >
    > Chad Armstrong
  • On Jan 17, 2008, at 4:37 AM, Christiaan Hofman wrote:

    > Sounds like really bad practice to override a key feature in a
    > generic superclass. You should do your override in a subclass. And
    > otherwise use [super keyDown:].

    Yes.  He should create a custom subclass of NSWindow and override
    keyDown: there.  He can set the window subclass in InterfaceBuilder
    for any windows that need it so it won't affect the alert panel.
previous month january 2008 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 31      
Go to today