I have an AppKit application that I'm converting to SwiftUI and I'm having some difficulty understanding how to model a Table
with single click and double click behavior. My table is relatively simple, it has 3 columns (possibly more in the future), the first with an icon, and the latter two with text. The two text fields are sortable, and the table requires multi-selection and row-based keybindings (return
, delete
), as well as double-click.
The first surprising thing is that I cannot add those behaviors on the TableRow
or even the TableCell
but rather the views inside of them. That means the subviews must occupy the entire TableCell
or else they will not capture the click event. That means repeating the same gestures for the contents of every cell (or wrapping all with the same view)?
The second surprise is that adding an onTapGesture(count: 2)
prevents the default row selection gesture from firing. Do I really need to re-implement row selection if I want double click support as well?
Adding a onTapGesture(count: 2)
to the Table
itself (analogous to NSTableView -setDoubleAction:
) has no effect that I can tell.
I'm hoping I'm missing something. Supporting selection and double-click seems like table-stakes for a table view.