14

I think it's a first responder problem, but I'm not sure. I'm implementing an edit window for data in a table view. Very similar in concept to the UI for editing filter rules in Mail.app.

I have an editing window that I attach to my primary window with:

[NSApp beginSheet: criteriaEditPanel 
   modalForWindow: [self window] 
    modalDelegate: self 
   didEndSelector: @selector(criteriaEditDidEnd:returnCode:contextInfo:) 
      contextInfo: (void *)[criteriaList objectAtIndex: index]];

The panel displays properly, from the title bar of the main window. I can manipulate the pop-up controls on the panel with the mouse, but I can't edit the text fields and I can't tab between fields. Everything else works fine. Any ideas?

joe

Flyingdiver
  • 2,142
  • 13
  • 18

1 Answers1

38

Solved. Believe it or not, you have to have the Title Bar enabled for the panel, even though it's never visible when displayed as a Sheet. When enabled it in IB, keyboard input started working.

@spudwaffle - none of the objects had Refuse First Responder checked.

Flyingdiver
  • 2,142
  • 13
  • 18
  • 3
    I understand this to mean that the style mask of the sheet window (not the parent window) must include NSTitledWindowMask, or check the IB box "Title Bar." Also, I saw this issue in a non-document app, using the new (10.9) NSWindow sheet API. – Paul Collins Mar 01 '14 at 19:58
  • That's correct, Paul. The panel you're using as the sheet, not the parent. – Flyingdiver Apr 06 '14 at 16:30
  • PLEASE COPY THIS ANSWER SOMEWHERE! – Marek H Oct 30 '17 at 10:23
  • @MarekH Other than here? Why? – Flyingdiver Nov 02 '17 at 16:19
  • Took me few searches till this one showed. I was looking for "first resonder incorrect modal window". My first responder was the window that showed the modal, not the modal itself. – Marek H Nov 02 '17 at 16:54
  • 1
    Confirmed here in a document-based 10.9 NSWindow sheet API app; this is still an issue at least as late as macOS 10.13.4. (and, yes, future person, we did all think we were so modern back in 2018) – Tommy Apr 04 '18 at 03:18
  • Saved me a lot of time. Title Bar must be enabled on sheets. Works on other sheets too (not only Document). – tambeen Aug 16 '18 at 03:15
  • 2
    @Tommy: You'll be happy to know that here in the amazing future that is 2021, this is still an issue in macOS 11.1 Big Sur! (And don't worry about the next few years, you won't believe how great things are going in 2020 and 2021.) – Andrew Madsen Jan 15 '21 at 05:46