Document sheet not responding to keyboard events

2019-03-24 13:45发布

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

1条回答
Rolldiameter
2楼-- · 2019-03-24 13:56

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.

查看更多
登录 后发表回答