diff --git a/changes/1156.bugfix.rst b/changes/1156.bugfix.rst new file mode 100644 index 0000000000..cd4c54d426 --- /dev/null +++ b/changes/1156.bugfix.rst @@ -0,0 +1 @@ +TableViews on macOS will no longer crash if a drag operation is initiated from inside the table. diff --git a/cocoa/src/toga_cocoa/widgets/table.py b/cocoa/src/toga_cocoa/widgets/table.py index d9c218e82d..0376833fc7 100644 --- a/cocoa/src/toga_cocoa/widgets/table.py +++ b/cocoa/src/toga_cocoa/widgets/table.py @@ -1,4 +1,4 @@ -from rubicon.objc import SEL, at, objc_method, objc_property +from rubicon.objc import SEL, NSPoint, at, objc_method, objc_property from travertino.size import at_least import toga @@ -21,6 +21,16 @@ class TogaTable(NSTableView): interface = objc_property(object, weak=True) impl = objc_property(object, weak=True) + # NSTableView methods + @objc_method + def canDragRowsWithIndexes_atPoint_( + self, + rowIndexes, + mouseDownPoint: NSPoint, + ) -> bool: + # Disable all drags + return False + # TableDataSource methods @objc_method def numberOfRowsInTableView_(self, table) -> int: @@ -140,6 +150,7 @@ def create(self): ) self.native_table.usesAlternatingRowBackgroundColors = True self.native_table.allowsMultipleSelection = self.interface.multiple_select + self.native_table.allowsColumnReordering = False # Create columns for the table self.columns = [] diff --git a/examples/table/table/app.py b/examples/table/table/app.py index 95449ec9a3..b9a5644e6b 100644 --- a/examples/table/table/app.py +++ b/examples/table/table/app.py @@ -11,7 +11,7 @@ class ExampleTableApp(toga.App): lbl_fontsize = None def load_data(self): - yak = toga.Icon.TOGA_ICON + yak = toga.Icon.DEFAULT_ICON red = toga.Icon("icons/red") green = toga.Icon("icons/green") diff --git a/examples/tutorial2/tutorial/app.py b/examples/tutorial2/tutorial/app.py index c17d89cf28..f3795135cb 100644 --- a/examples/tutorial2/tutorial/app.py +++ b/examples/tutorial2/tutorial/app.py @@ -92,7 +92,7 @@ def startup(self): action2, text="Action 2", tooltip="Perform action 2", - icon=toga.Icon.TOGA_ICON, + icon=toga.Icon.DEFAULT_ICON, group=things, )