我有一個NSTableView放置在NSView的頂部。我想在NSView上單擊鼠標指針時取消選擇NSTableView。如何實現這一目標?取消選擇NSTableView時,點擊表格外的某處
1
A
回答
6
我知道這是舊的,但一個選項是繼承NSTableView的並覆蓋其鼠標按下:
- (void)mouseDown:(NSEvent *)event {
[super mouseDown:event];
NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil];
NSInteger row = [self rowAtPoint:point];
if (row == -1) { // We didn't click any row
[self deselectAll:nil];
}
}
斯威夫特3版本:
override open func mouseDown(with event: NSEvent) {
super.mouseDown(with: event)
let point = convert(event.locationInWindow, from: nil)
let rowIndex = row(at: point)
if rowIndex < 0 { // We didn't click any row
deselectAll(nil)
}
}
相關問題
- 1. 點擊時選擇/取消選擇UIButton
- 2. 上點擊單元格,選擇/取消選擇複選框
- 3. 不要取消選擇基於NStableview的視圖中的選定行當被點擊外
- 4. 在選擇/取消選擇時調整表格單元格
- 5. 如何在javascript外點擊某處時關閉日期選擇器?
- 6. NSTableView的選擇和亮點
- 7. 點擊取消選擇之前選擇的選項
- 8. Vaadin - ListSelect組件取消選擇點擊
- 9. 通過點擊取消選擇NSCollectionViewItem
- 10. UITableView點擊以取消選擇單元
- 11. 如何在某處點擊時「下拉」選擇?
- 12. 如何在外部點擊時取消選中複選框?
- 13. 當點擊另一個表格時取消選擇表格視圖單元格中的按鈕
- 14. Openlayers3點擊外部特徵取消選擇所有特徵
- 15. 如何在點擊取消時恢復單選按鈕選擇?
- 16. 當點擊另一個時,選擇/取消選中框
- 17. 在選擇框外單擊時撤消選擇選項
- 18. jQuery UI可選 - 不要取消選擇某些元素的點擊字段
- 19. jQuery的選擇和取消選擇多個輸入點擊
- 20. 取消Dialogfragment點擊外部
- 21. Jquery選擇取消選擇複選框點擊標題
- 22. 要取消選擇表格單元格
- 23. WPF的Datagrid - 取消選擇的項目(S)在DataGrid點擊空格時
- 24. 當表格行被點擊時選中和取消選中複選框
- 25. 多個選擇列表在點擊時移動鼠標時取消選擇所有選擇
- 26. 在NSTableView中取消選擇一行需要時間
- 27. 取消選擇NSTableView行時出現異常
- 28. 複選框選擇/取消選擇中繼器時點擊文本
- 29. winrt在外部單擊時取消選擇ListView項目
- 30. NSTableView中的NSButtonCell:點擊處理
你是什麼意思「之上」?您通常不應該在視圖層次結構中將其中一個視圖置於其同一個視圖之上;你應該只在其他視圖中放置視圖*。換句話說,兩個兄弟姐妹的觀點不應該重疊;你應該讓其中一個爲子視圖。 – 2010-08-17 10:07:15
那是正確的。一個是另一個的子視圖。但是,如何實現刪除表的功能? – Subrat 2010-08-18 04:07:37
你是什麼意思的「取消選擇表視圖」?撤消其第一響應者狀態,或取消選擇其中的任何選定行? – 2010-08-18 04:51:12