Skip to content

Commit d64f59e

Browse files
Merge pull request mantidproject#35998 from mantidproject/35583_show_data_right_click
Improve right-click behaviour in table view
2 parents 6c22dee + f2eab6b commit d64f59e

File tree

2 files changed

+19
-4
lines changed
  • docs/source/release/v6.8.0/Workbench/Bugfixes
  • qt/python/mantidqt/mantidqt/widgets/workspacedisplay/matrix

2 files changed

+19
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Improved right-click behaviour in the table view (e.g. "Show Data") when right-clicking on a row/column header.

qt/python/mantidqt/mantidqt/widgets/workspacedisplay/matrix/view.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,31 @@ def bin_context_menu_opened(self, position):
169169
:param position: The position to open the menu, e.g. where
170170
the mouse button was clicked
171171
"""
172-
context_menu = self.setup_bin_context_menu(self.currentWidget())
173-
context_menu.exec_(self.currentWidget().horizontalHeader().mapToGlobal(position))
172+
table = self.currentWidget()
173+
context_menu = self.setup_bin_context_menu(table)
174+
header = table.horizontalHeader()
175+
# If you right-click on a column header, then select that column, unless you're already clicking
176+
# inside a selected column
177+
index_of_selected_column = header.logicalIndexAt(position)
178+
if index_of_selected_column not in [x.column() for x in table.selectionModel().selectedColumns()]:
179+
table.selectColumn(index_of_selected_column)
180+
context_menu.exec_(header.mapToGlobal(position))
174181

175182
def spectra_context_menu_opened(self, position):
176183
"""
177184
Open the context menu in the correct location
178185
:param position: The position to open the menu, e.g. where
179186
the mouse button was clicked
180187
"""
181-
context_menu = self.setup_spectra_context_menu(self.currentWidget())
182-
context_menu.exec_(self.currentWidget().verticalHeader().mapToGlobal(position))
188+
table = self.currentWidget()
189+
context_menu = self.setup_spectra_context_menu(table)
190+
header = table.verticalHeader()
191+
# If you right-click on a row header, then select that row, unless you're already clicking
192+
# inside a selected row
193+
index_of_selected_row = header.logicalIndexAt(position)
194+
if index_of_selected_row not in [x.row() for x in table.selectionModel().selectedRows()]:
195+
table.selectRow(index_of_selected_row)
196+
context_menu.exec_(header.mapToGlobal(position))
183197

184198
def setup_plot_bin_actions(self, context_menu, table):
185199
plot_bin_action = QAction(self.GRAPH_ICON, "Plot bin (values only)", self)

0 commit comments

Comments
 (0)