setInteractionFlags( EditFlags );
//setInteractionFlag( TraceBoundingRect );
//setInteractionFlag( DraggingByMiddleButton );
- //setInteractionFlag( ImmediateSelection );
+ //setInteractionFlag( ImmediateContextMenu );
+ setInteractionFlag( ImmediateSelection );
// background
setBackgroundBrush( QBrush( Qt::white ) );
// advanced flags
TraceBoundingRect = 0x0008,
DraggingByMiddleButton = 0x0010,
- ImmediateSelection = 0x0020
+ ImmediateContextMenu = 0x0020,
+ ImmediateSelection = 0x0040,
};
Q_DECLARE_FLAGS( InteractionFlags, InteractionFlag )
{
if( GraphicsView_ViewPort* aViewPort = getActiveViewPort() )
{
- if( e->button() == Qt::RightButton &&
- aViewPort->hasInteractionFlag( GraphicsView_ViewPort::ImmediateSelection ) &&
- aViewPort->nbSelected() < 1 )
- {
- // If the 'immediate selection' mode is enabled,
- // try to perform selection before invoking context menu
- bool append = bool ( e->modifiers() & GraphicsView_Selector::getAppendKey() );
- getSelector()->select( QRectF(), append );
- }
- else if( e->button() == Qt::LeftButton &&
+ bool append = bool ( e->modifiers() & GraphicsView_Selector::getAppendKey() );
+ if( e->button() == Qt::LeftButton &&
aViewPort->hasInteractionFlag( GraphicsView_ViewPort::Pulling ) &&
!aViewPort->isSelectByRect() &&
!aViewPort->isDragging() &&
QPoint p = aViewPort->mapFromScene( e->scenePos() );
aViewPort->startSelectByRect( p.x(), p.y() );
}
+ else if( !append &&
+ e->button() != Qt::MidButton &&
+ aViewPort->hasInteractionFlag( GraphicsView_ViewPort::ImmediateSelection ) &&
+ aViewPort->nbSelected() < 2 )
+ {
+ // Do not perform 'immediate selection' if the multiple objects are already selected
+ getSelector()->select( QRectF(), append );
+ }
+ else if( e->button() == Qt::RightButton &&
+ aViewPort->hasInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu ) &&
+ aViewPort->nbSelected() < 1 )
+ {
+ // If the 'immediate context menu' mode is enabled,
+ // try to perform selection before invoking context menu
+ //bool append = bool ( e->modifiers() & GraphicsView_Selector::getAppendKey() );
+ getSelector()->select( QRectF(), append );
+ }
}
}
}