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
(self, event)
| 684 | self.PopupMenu(menu) |
| 685 | |
| 686 | def click(self, event): |
| 687 | """ |
| 688 | Handle click event on modules. |
| 689 | |
| 690 | This is only useful for the State column. If multiple items are selected, |
| 691 | and we have clicked the State column, iterate through the selections and |
| 692 | change State |
| 693 | """ |
| 694 | |
| 695 | clickedRow, _, col = self.HitTestSubItem(event.Position) |
| 696 | |
| 697 | # only do State column and ignore invalid rows |
| 698 | if clickedRow != -1 and clickedRow not in self.blanks and col == self.getColIndex(State): |
| 699 | selectedRows = [] |
| 700 | currentRow = self.GetFirstSelected() |
| 701 | |
| 702 | while currentRow != -1 and clickedRow not in self.blanks: |
| 703 | selectedRows.append(currentRow) |
| 704 | currentRow = self.GetNextSelected(currentRow) |
| 705 | |
| 706 | if clickedRow not in selectedRows: |
| 707 | try: |
| 708 | selectedMods = [self.mods[clickedRow]] |
| 709 | except IndexError: |
| 710 | return |
| 711 | else: |
| 712 | selectedMods = self.getSelectedMods() |
| 713 | |
| 714 | click = "ctrl" if event.GetModifiers() == wx.MOD_CONTROL or event.middleIsDown else "right" if event.GetButton() == 3 else "left" |
| 715 | |
| 716 | try: |
| 717 | mainMod = self.mods[clickedRow] |
| 718 | except IndexError: |
| 719 | return |
| 720 | if mainMod.isEmpty: |
| 721 | return |
| 722 | fitID = self.mainFrame.getActiveFit() |
| 723 | fit = Fit.getInstance().getFit(fitID) |
| 724 | if mainMod not in fit.modules: |
| 725 | return |
| 726 | mainPosition = fit.modules.index(mainMod) |
| 727 | if event.GetModifiers() == wx.MOD_ALT: |
| 728 | positions = getSimilarModPositions(fit.modules, mainMod) |
| 729 | else: |
| 730 | positions = [] |
| 731 | for position, mod in enumerate(fit.modules): |
| 732 | if mod in selectedMods: |
| 733 | positions.append(position) |
| 734 | self.mainFrame.command.Submit(cmd.GuiChangeLocalModuleStatesCommand( |
| 735 | fitID=fitID, |
| 736 | mainPosition=mainPosition, |
| 737 | positions=positions, |
| 738 | click=click)) |
| 739 | |
| 740 | # update state tooltip |
| 741 | tooltip = self.activeColumns[col].getToolTip(self.mods[clickedRow]) |
| 742 | if tooltip: |
| 743 | self.SetToolTip(tooltip) |
no test coverage detected