我有一个NSPopover的NSComboBox子项。弹出窗口是瞬态的,并配置为在用户单击其边界外时忽略。
当其组合框弹出窗口处于活动状态并显示时,当用户按下弹出窗口拥有视图时,视图会按预期接收鼠标,弹出框消失,组合框解除,但下一个mouseUp永远不会被风景。
事实证明,NSComboBoxCell的trackMouse方法(跟踪循环)在收到mouseUp之前没有返回,但与mouseDown的情况不同,它将它很好地重新调整到点击的视图,它从不传播mouseUp。
我不得不使用以下NSComboBoxCell trackMouse覆盖来解决此问题。
有没有人事先看过这个问题或了解可能发生的事情?
--------
- (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame
ofView:(NSView *)controlView untilMouseUp:(BOOL)untilMouseUp {
BOOL trackingResult = [super trackMouse:theEvent inRect:cellFrame
ofView:controlView untilMouseUp:untilMouseUp];
// If we were dismissed due to mouse event and the current
// event (that NSComboBoxCell is currently eating), just redispatch
// it so it lands with its intended destination.
if (trackingResult) {
NSEvent* currentEvent = [NSApp currentEvent];
if (currentEvent.type == NSLeftMouseUp && currentEvent.window != nil) {
[NSApp postEvent:currentEvent atStart:YES];
}
}
return trackingResult;
}