def click(self, event): """ Handle click event on modules. This is only useful for the State column. If multiple items are selected, and we have clicked the State column, iterate through the selections and change State """ row, _, col = self.HitTestSubItem(event.Position) # only do State column and ignore invalid rows if row != -1 and row not in self.blanks and col == self.getColIndex( State): sel = [] curr = self.GetFirstSelected() while curr != -1 and row not in self.blanks: sel.append(curr) curr = self.GetNextSelected(curr) if row not in sel: mods = [self.mods[self.GetItemData(row)]] else: mods = self.getSelectedMods() fitID = self.mainFrame.getActiveFit() ctrl = event.cmdDown or event.middleIsDown click = "ctrl" if ctrl is True else "right" if event.GetButton( ) == 3 else "left" self.mainFrame.command.Submit( cmd.GuiChangeLocalModuleStatesCommand( fitID=fitID, mainPosition=self.mods[self.GetItemData(row)].modPosition, positions=[mod.modPosition for mod in mods], click=click)) # update state tooltip tooltip = self.activeColumns[col].getToolTip( self.mods[self.GetItemData(row)]) if tooltip: self.SetToolTip(tooltip) else: event.Skip()
def click(self, event): """ Handle click event on modules. This is only useful for the State column. If multiple items are selected, and we have clicked the State column, iterate through the selections and change State """ clickedRow, _, col = self.HitTestSubItem(event.Position) # only do State column and ignore invalid rows if clickedRow != -1 and clickedRow not in self.blanks and col == self.getColIndex( State): selectedRows = [] currentRow = self.GetFirstSelected() while currentRow != -1 and clickedRow not in self.blanks: selectedRows.append(currentRow) currentRow = self.GetNextSelected(currentRow) if clickedRow not in selectedRows: try: selectedMods = [self.mods[clickedRow]] except IndexError: return else: selectedMods = self.getSelectedMods() click = "ctrl" if event.GetModifiers( ) == wx.MOD_CONTROL or event.middleIsDown else "right" if event.GetButton( ) == 3 else "left" try: mainMod = self.mods[clickedRow] except IndexError: return if mainMod.isEmpty: return fitID = self.mainFrame.getActiveFit() fit = Fit.getInstance().getFit(fitID) if mainMod not in fit.modules: return mainPosition = fit.modules.index(mainMod) if event.GetModifiers() == wx.MOD_ALT: positions = getSimilarModPositions(fit.modules, mainMod) else: positions = [] for position, mod in enumerate(fit.modules): if mod in selectedMods: positions.append(position) self.mainFrame.command.Submit( cmd.GuiChangeLocalModuleStatesCommand( fitID=fitID, mainPosition=mainPosition, positions=positions, click=click)) # update state tooltip tooltip = self.activeColumns[col].getToolTip(self.mods[clickedRow]) if tooltip: self.SetToolTip(tooltip) else: event.Skip()