On windows with Ctrl is pressed, or on Mac, when right-click on any item happens, the item doesn't get selected. This method ensures that only clicked item is selected.
(self, clickedPos)
| 301 | return propWidth |
| 302 | |
| 303 | def ensureSelection(self, clickedPos): |
| 304 | """ |
| 305 | On windows with Ctrl is pressed, or on Mac, when right-click on any item happens, |
| 306 | the item doesn't get selected. This method ensures that only clicked item is selected. |
| 307 | """ |
| 308 | if ( |
| 309 | 'wxMac' in wx.PlatformInfo or |
| 310 | ('wxMSW' in wx.PlatformInfo and wx.GetMouseState().GetModifiers() == wx.MOD_CONTROL) |
| 311 | ): |
| 312 | if clickedPos != -1: |
| 313 | selectedPoss = self.getSelectedRows() |
| 314 | if clickedPos not in selectedPoss: |
| 315 | self.unselectAll() |
| 316 | self.Select(clickedPos) |
| 317 | # Change focus only when we manipulate selection |
| 318 | focusedPos = self.GetFocusedItem() |
| 319 | if clickedPos != focusedPos: |
| 320 | self.Focus(clickedPos) |