Strange controls behaviour in sheet modal window

Graham Cox

Hi all,

I have a problem with controls in a sheet-modal window.

The button control’s target and action are set up to call a method in File’s Owner, which is a NSWindowController subclass that owns the sheet. The sheet displays fine, and all the outlets are correctly set. The controls all appear normal and can be clicked. The target and action in the button’s cell appear to be correctly set (checking in -awakeFromNib). But when I click the button, I just get a beep, and the action method is never called.

The stack trace of the beep is:

#0 0x00007fff323c4937 in NSBeep ()
#1 0x00007fff3239079c in -[NSControl sendAction:to:] ()
#2 0x00007fff3239069f in __26-[NSCell _sendActionFrom:]_block_invoke ()
#3 0x00007fff323905a5 in -[NSCell _sendActionFrom:] ()
#4 0x00007fff323d1858 in -[NSButtonCell _sendActionFrom:] ()
#5 0x00007fff3238ee06 in -[NSCell trackMouse:inRect:ofView:untilMouseUp:] ()
#6 0x00007fff323d159f in -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] ()
#7 0x00007fff3238d8a4 in -[NSControl mouseDown:] ()
#8 0x00007fff32a88a01 in -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] ()
#9 0x00007fff32a85658 in -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] ()
#10 0x00007fff32a84904 in -[NSWindow(NSEventRouting) sendEvent:] ()
#11 0x00007fff328e5937 in -[NSApplication(NSEvent) sendEvent:] ()
#12 0x00007fff32147861 in -[NSApplication run] ()

I’ve made literally hundreds of sheet-modal dialogs over the years and have never run into this problem.

I’m showing the sheet using -beginSheet:completionHandler: , and as mentioned I’ve verified that all outlets, targets and actions appear to be set as expected. The sheet is made key as expected and the first text field is selected as initial responder.

Any ideas? This is on 10.13.1, Objective-C.


Join to automatically receive all group messages.