diff --git a/common/tool/tool_dispatcher.cpp b/common/tool/tool_dispatcher.cpp index 747b2bf6d9..da052004ca 100644 --- a/common/tool/tool_dispatcher.cpp +++ b/common/tool/tool_dispatcher.cpp @@ -69,6 +69,9 @@ struct TOOL_DISPATCHER::BUTTON_STATE ///< Point where dragging has started (in world coordinates). VECTOR2D dragOrigin; + ///< Point where dragging has started (in screen coordinates). + VECTOR2D dragOriginScreen; + ///< Point where click event has occurred. VECTOR2D downPosition; @@ -192,7 +195,10 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti st->downTimestamp = wxGetLocalTimeMillis(); if( !st->pressed ) // save the drag origin on the first click only + { st->dragOrigin = m_lastMousePos; + st->dragOriginScreen = m_lastMousePosScreen; + } st->downPosition = m_lastMousePos; st->pressed = true; @@ -225,7 +231,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti if( wxGetLocalTimeMillis() - st->downTimestamp > DragTimeThreshold ) st->dragging = true; #endif - VECTOR2D offset = getView()->ToScreen( m_lastMousePos - st->dragOrigin, false ); + VECTOR2D offset = m_lastMousePosScreen - st->dragOriginScreen; if( abs( offset.x ) > m_sysDragMinX || abs( offset.y ) > m_sysDragMinY ) st->dragging = true; @@ -481,6 +487,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) if( m_toolMgr->GetViewControls() ) { pos = m_toolMgr->GetViewControls()->GetMousePosition(); + m_lastMousePosScreen = m_toolMgr->GetViewControls()->GetMousePosition( false ); if( pos != m_lastMousePos ) { diff --git a/include/tool/tool_dispatcher.h b/include/tool/tool_dispatcher.h index 5ef74100b6..f7c9d81c96 100644 --- a/include/tool/tool_dispatcher.h +++ b/include/tool/tool_dispatcher.h @@ -120,6 +120,9 @@ private: ///< The last mouse cursor position (in world coordinates). VECTOR2D m_lastMousePos; + ///< The last mouse cursor position (in screen coordinates). + VECTOR2D m_lastMousePosScreen; + ///< State of mouse buttons. std::vector m_buttons;