diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index 21a03dc933..ed79893fb8 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -179,7 +179,9 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th // does nothing if previously detected object is equal to the current one if (myMainSel->OnePicked()->Selectable() == myLastPicked) { - return AIS_SOD_OnlyOneDetected; + return myLastPicked->State() == 1 + ? AIS_SOD_Selected + : AIS_SOD_OnlyOneDetected; } // Previously detected object is unhilighted if it is not selected or hilighted @@ -216,10 +218,9 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th toUpdateViewer = Standard_True; } - if (myLastPicked->State() == 1) - { - aStatus = AIS_SOD_Selected; - } + aStatus = myLastPicked->State() == 1 + ? AIS_SOD_Selected + : AIS_SOD_OnlyOneDetected; } } else @@ -243,6 +244,7 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th } myLastinMain.Nullify(); + myLastPicked.Nullify(); } if (toUpdateViewer) @@ -257,7 +259,6 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th } } - myLastPicked.Nullify(); mylastmoveview = theView; return aStatus; } diff --git a/src/ViewerTest/ViewerTest_EventManager.cxx b/src/ViewerTest/ViewerTest_EventManager.cxx index d9543e88b2..2b531c598e 100644 --- a/src/ViewerTest/ViewerTest_EventManager.cxx +++ b/src/ViewerTest/ViewerTest_EventManager.cxx @@ -90,7 +90,9 @@ void ViewerTest_EventManager::Select (const Standard_Integer theXPMin, const Standard_Integer theYPMax) { #define IS_FULL_INCLUSION Standard_True - if (myView.IsNull()) + if (myView.IsNull() + || Abs (theXPMax - theXPMin) < 2 + || Abs (theYPMax - theYPMin) < 2) { return; } @@ -117,7 +119,9 @@ void ViewerTest_EventManager::ShiftSelect (const Standard_Integer theXPMin, const Standard_Integer theXPMax, const Standard_Integer theYPMax) { - if (myView.IsNull()) + if (myView.IsNull() + || Abs (theXPMax - theXPMin) < 2 + || Abs (theYPMax - theYPMin) < 2) { return; } diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index 9e3d762a01..f4c5cfec2e 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -193,7 +193,7 @@ int Y_Motion = 0; int X_ButtonPress = 0; // Last ButtonPress position int Y_ButtonPress = 0; Standard_Boolean IsDragged = Standard_False; -Standard_Boolean DragFirst; +Standard_Boolean DragFirst = Standard_False; //============================================================================== @@ -1891,24 +1891,16 @@ static LRESULT WINAPI AdvViewerWindowProc( HWND hwnd, } break; case WM_LBUTTONUP: - IsDragged = Standard_False; - if( !DragFirst ) + if (!DragFirst) { HDC hdc = GetDC( hwnd ); SelectObject( hdc, GetStockObject( HOLLOW_BRUSH ) ); SetROP2( hdc, R2_NOT ); Rectangle( hdc, X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion ); ReleaseDC( hwnd, hdc ); - - const Handle(ViewerTest_EventManager) EM = - ViewerTest::CurrentEventManager(); - if ( fwKeys & MK_SHIFT ) - EM->ShiftSelect( min( X_ButtonPress, X_Motion ), max( Y_ButtonPress, Y_Motion ), - max( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion )); - else - EM->Select( min( X_ButtonPress, X_Motion ), max( Y_ButtonPress, Y_Motion ), - max( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion )); + VT_ProcessButton1Release (fwKeys & MK_SHIFT); } + IsDragged = Standard_False; return ViewerWindowProc( hwnd, Msg, wParam, lParam ); case WM_LBUTTONDOWN: