Skip to content

Commit

Permalink
Fix issue with context menu not targeting display panel when not focu…
Browse files Browse the repository at this point in the history
…sed.
  • Loading branch information
cmeyer committed May 30, 2024
1 parent 08b443a commit 4a3e35d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions nion/swift/DocumentController.py
Original file line number Diff line number Diff line change
Expand Up @@ -2755,6 +2755,7 @@ def _get_action_context_for_display_items(self, display_items: typing.Sequence[D
if not data_item_1 in used_data_items:
used_data_items.append(data_item_1)
selected_graphics = used_display_item.selected_graphics if used_display_item else list()
selected_display_panel = selected_display_panel or (display_panel if len(used_display_panels) == 1 else None)
return DocumentController.ActionContext(typing.cast("Application.Application", self.app), self, focus_widget,
used_display_panel, used_display_panels, selected_display_panel, model,
used_display_item, used_display_items, crop_graphic, selected_graphics,
Expand Down
9 changes: 9 additions & 0 deletions nion/swift/test/Workspace_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,15 @@ def test_workspace_split_with_another_panel_focused(self):
action_context = document_controller._get_action_context_for_display_items(document_controller.selected_display_items, workspace_controller.display_panels[0])
document_controller.perform_action_in_context("workspace.split_vertical", action_context)

def test_workspace_split_with_another_no_panel_focused(self):
with TestContext.create_memory_context() as test_context:
document_controller = test_context.create_document_controller()
workspace_controller = document_controller.workspace_controller
self.assertEqual(1, len(workspace_controller.display_panels))
document_controller.selected_display_panel = None
action_context = document_controller._get_action_context_for_display_items(document_controller.selected_display_items, workspace_controller.display_panels[0])
document_controller.perform_action_in_context("workspace.split_vertical", action_context)

def test_workspace_split_horizontal_does_not_create_extra_splits(self):
with TestContext.create_memory_context() as test_context:
document_controller = test_context.create_document_controller()
Expand Down

0 comments on commit 4a3e35d

Please sign in to comment.