Select items

        When the mouse button is pressed, the selection is updated.

        :param event: The button event
421379
def on_button_press(self, event):
        
        if event.get_button()[1] not in self._buttons:
            return False  # Only handle events for registered buttons (left mouse clicks)

        if event.get_state()[1] & constants.RUBBERBAND_MODIFIER:
            return False  # Mouse clicks with pressed shift key are handled in another tool

        # Special case: moving the NameView
        # This is only allowed, if the hovered item is a NameView and the Ctrl-key is pressed and the only selected
        # item is the parental StateView. In this case, the selection and _item will no longer be looked at,
        # but only _move_name_v
        self._item = self.get_item()
        if isinstance(self._item, NameView):
            selected_items = self.view.selected_items
            if event.get_state()[1] & Gdk.ModifierType.CONTROL_MASK and len(selected_items) == 1 and next(iter(selected_items)) is \
                    self._item.parent:
                self._move_name_v = True
            else:
                self._item = self._item.parent

        if not self._move_name_v:
            self._old_selection = self.view.selected_items
            if self._item not in self.view.selected_items:
                # When items are to be moved, a button-press should not cause any deselection.
                # However, the selection is stored, in case no move operation is performed.
                self.view.handle_new_selection(self._item)

        if not self.view.is_focus():
            self.view.grab_focus()

        return True
1226444
def on_button_release(self, event):
        
        self.queue_draw(self.view)
        x0, y0, x1, y1 = self.x0, self.y0, self.x1, self.y1
        rectangle = (min(x0, x1), min(y0, y1), abs(x1 - x0), abs(y1 - y0))
        selected_items = self.view.get_items_in_rectangle(rectangle, intersect=False)
        self.view.handle_new_selection(selected_items)

        return True
456200
def on_select(self, item, action):
        

        if not isinstance(item, int):
            item = self.items.index(item)

        self._on_select[item] = action
880761
@SuppressWarnings("unchecked")
    void onItemClick(ItemClickEvent event) {

        if (!event.isCtrlKey() && !event.isShiftKey()) {
            // don't interfere with multi-selection using control key
            if (event.getButton().equals(MouseButton.RIGHT) || (event.getPropertyId() == null)) {
                CmsUUID itemId = (CmsUUID)event.getItemId();
                Set<CmsUUID> value = (Set<CmsUUID>)getValue();
                if (value == null) {
                    select(itemId);
                } else if (!value.contains(itemId)) {
                    setValue(null);
                    select(itemId);
                }
                m_menu.setEntries(getMenuEntries(), (Set<CmsUUID>)getValue());
                m_menu.openForTable(event, this);
            } else if (event.getButton().equals(MouseButton.LEFT) && PROP_NAME.equals(event.getPropertyId())) {
                Item item = event.getItem();
                CmsUUID id = (CmsUUID)item.getItemProperty(PROP_ID).getValue();
                m_manager.openSubView(
                    A_CmsWorkplaceApp.addParamToState(CmsProjectManager.PATH_NAME_FILES, "projectId", id.toString()),
                    true);
            }
        }
    }
288935
void onItemClick(MouseEvents.ClickEvent event, Object itemId, Object propertyId) {

        if (!event.isCtrlKey() && !event.isShiftKey()) {

            changeValueIfNotMultiSelect(itemId);

            // don't interfere with multi-selection using control key
            if (event.getButton().equals(MouseButton.RIGHT) || (propertyId == null)) {
                m_menu.setEntries(getMenuEntries(), getSearchIndexNames());
                m_menu.openForTable(event, itemId, propertyId, this);
            } else if (event.getButton().equals(MouseButton.LEFT) && TableProperty.Name.equals(propertyId)) {
                showSourcesWindow(((I_CmsSearchIndex)((Set<?>)getValue()).iterator().next()).getName());
            }
        }
    }
1282639
def on_click(self, event):
        
        button = event["button"]
        if button == self.button_pause:
            if self.state == "STOP":
                self.py3.command_run("mocp --play")
            else:
                self.py3.command_run("mocp --toggle-pause")
        elif button == self.button_stop:
            self.py3.command_run("mocp --stop")
        elif button == self.button_next:
            self.py3.command_run("mocp --next")
        elif button == self.button_previous:
            self.py3.command_run("mocp --prev")
        else:
            self.py3.prevent_refresh()
1280661
def hoverLeaveEvent( self, event ):
        
        super(XChartWidgetItem, self).hoverEnterEvent(event)
        
        self._hoveredPath = None
        self.update()
501449
def on_click(self, event):
        
        button = event["button"]
        if button in [1, 4, 5]:
            self.scrolling = True
            self._switch_selection()
        elif button == 3:
            self._apply()
1370746
def mousePressEvent(self, event):
        """"""
        index = self.indexAt(event.pos())
        if index.isValid():
            if index.column() == 0:
                self.edit(index, QtGui.QAbstractItemView.DoubleClicked, event)
            else:
                super(ProtocolView, self).mousePressEvent(event)
527720
def mouseMoveEvent(self, event):
        
        if self.hoverMode() != XTreeWidget.HoverMode.NoHover:
            item  = self.itemAt(event.pos())
            col   = self.columnAt(event.pos().x())
            hitem = self.hoveredItem()
            hcol  = self.hoveredColumn()

            if (id(item), col) != (id(hitem), hcol):
                if ( item ):
                    self._hoveredItem = weakref.ref(item)
                else:
                    self._hoveredItem = None

                self._hoveredColumn = col

                rect  = self.visualItemRect(item)
                hrect = self.visualItemRect(hitem)

                rect.setWidth(self.viewport().width())
                hrect.setWidth(self.viewport().width())

                self.viewport().update(rect)
                self.viewport().update(hrect)

        super(XTreeWidget, self).mouseMoveEvent(event)
914287
def mousePressEvent( self, event ):
        
        XPopupWidget.hideToolTip()
        
        # update the current date
        self.setCurrentDate(self.dateAt(event.scenePos()))
        
        super(XCalendarScene, self).mousePressEvent(event)
816836
def mouseDoubleClickEvent(self, event):
        
        item = self.itemAt(event.pos())
        column = self.columnAt(event.pos().x())
        
        mid_button = event.button() == QtCore.Qt.MidButton
        ctrl_click = event.button() == QtCore.Qt.LeftButton and \
                     event.modifiers() == QtCore.Qt.ControlModifier
        
        if mid_button or ctrl_click:
            self.itemMiddleDoubleClicked.emit(item, column)
        elif event.button() == QtCore.Qt.RightButton:
            self.itemRightDoubleClicked.emit(item, column)
        else:
            super(XTreeWidget, self).mouseDoubleClickEvent(event)
217436
def selection_changed(self, widget, event=None):
        """"""
        # do not forward cursor selection updates if state update is running
        # TODO maybe make this generic for respective abstract controller
        if self._state_which_is_updated:
            return
        super(StateMachineTreeController, self).selection_changed(widget, event)
348515
def mouseMoveEvent(self, event):
        
        line_number = self.editor.get_linenumber_from_mouse_event(event)
        block = self.editor.document().findBlockByNumber(line_number-1)
        data = block.userData()

        # this disables pyflakes messages if there is an active drag/selection
        # operation
        check = self._released == -1
        if data and data.code_analysis and check:
            self.editor.show_code_analysis_results(line_number,
                                                   data)
        else:
            self.editor.hide_tooltip()

        if event.buttons() == Qt.LeftButton:
            self._released = line_number
            self.editor.select_lines(self._pressed, self._released)
807170
def mousePressEvent(self, event):
        
        self._moveItemStarted = False
        rect = QtCore.QRect(0, 0, 12, self.height())

        # drag the tab off
        if not self._locked and rect.contains(event.pos()):
            tabbar = self.parent()
            panel = tabbar.parent()

            index = tabbar.indexOf(self)
            view = panel.widget(index)
            pixmap = QtGui.QPixmap.grabWidget(view)

            drag = QtGui.QDrag(panel)
            data = QtCore.QMimeData()
            data.setData('x-application/xview/tabbed_view', QtCore.QByteArray(str(index)))
            drag.setMimeData(data)
            drag.setPixmap(pixmap)

            if not drag.exec_():
                cursor = QtGui.QCursor.pos()
                geom = self.window().geometry()
                if not geom.contains(cursor):
                    view.popout()

        # allow moving indexes around
        elif not self._locked and self.isActive():
            self._moveItemStarted = self.parent().count() > 1

        else:
            self.activate()

        super(XViewPanelItem, self).mousePressEvent(event)
819638
def enterEvent( self, event ):
        
        item = self.trackerItem()
        if ( item ):
            item.setVisible(True)
757997
def select_item(self, items):
        
        if not items:
            return
        elif not hasattr(items, "__iter__"):
            items = (items,)
        selection_changed = False
        with self._suppress_selection_events():
            for item in items:
                self.queue_draw_item(item)
                if item is not None and item.model not in self._selection:
                    self._selection.add(item.model)
                    selection_changed = True
        if selection_changed:
            self.emit('selection-changed', self._get_selected_items())