Ignore:
Timestamp:
05/16/13 11:44:43 (11 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Selection follows mouse cursor in MenuPage widget.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/document/quickmenu.py

    r11519 r11523  
    2121    QStandardItemModel, QSortFilterProxyModel, QStyleOptionToolButton, 
    2222    QStylePainter, QStyle, QApplication, QStyledItemDelegate, 
    23     QStyleOptionViewItemV4, QSizeGrip, QCursor, QPolygon, QRegion 
     23    QStyleOptionViewItemV4, QSizeGrip, QPolygon, QRegion, QItemSelectionModel 
    2424) 
    2525 
     
    7979 
    8080        self.view().setItemDelegate(_MenuItemDelegate(self.view())) 
     81        self.view().entered.connect(self.__onEntered) 
     82        self.view().viewport().setMouseTracking(True) 
    8183        # Make sure the initial model is wrapped in a ItemDisableFilter. 
    8284        self.setModel(self.model()) 
     
    165167            height = 0 
    166168        return QSize(width, height) 
     169 
     170    def __onEntered(self, index): 
     171        self.view().selectionModel().select( 
     172            index, 
     173            QItemSelectionModel.ClearAndSelect 
     174        ) 
     175        self.view().setCurrentIndex(index) 
    167176 
    168177 
Note: See TracChangeset for help on using the changeset viewer.