From 31560df4539a9035726a572401315bc3ce3d1574 Mon Sep 17 00:00:00 2001 From: Rodney Date: Apr 02 2023 04:05:15 +0000 Subject: Merge pull request #4803 from shun-iwasawa/fix_define_sub_camera_with_stylus Fix "define sub camera" with stylus --- diff --git a/toonz/sources/toonz/sceneviewerevents.cpp b/toonz/sources/toonz/sceneviewerevents.cpp index b11a42a..19b8233 100644 --- a/toonz/sources/toonz/sceneviewerevents.cpp +++ b/toonz/sources/toonz/sceneviewerevents.cpp @@ -490,6 +490,10 @@ void SceneViewer::mouseMoveEvent(QMouseEvent *event) { if (m_gestureActive && m_touchDevice == QTouchDevice::TouchScreen) { return; } + // Strangely, mouseMoveEvent seems to be called once just after releasing + // tablet. This condition avoids to proceed further in such case. + if (event->buttons() != Qt::NoButton && m_mouseButton == Qt::NoButton) return; + // there are three cases to come here : // 1. on mouse is moved (no tablet is used) // 2. on tablet is moved, with middle or right button is pressed @@ -523,8 +527,12 @@ void SceneViewer::onMove(const TMouseEvent &event) { m_lastMousePos = curPos; if (m_editPreviewSubCamera) { - if (!PreviewSubCameraManager::instance()->mouseMoveEvent(this, event)) + if (!PreviewSubCameraManager::instance()->mouseMoveEvent(this, event)) { + if (m_tabletEvent && m_tabletState == StartStroke && m_tabletMove) { + m_tabletState = OnStroke; + } return; + } } // if the "compare with snapshot" mode is activated, change the mouse cursor @@ -740,8 +748,11 @@ void SceneViewer::onPress(const TMouseEvent &event) { m_mouseButton == Qt::LeftButton) return; else if (m_mouseButton == Qt::LeftButton && m_editPreviewSubCamera) { - if (!PreviewSubCameraManager::instance()->mousePressEvent(this, event)) + if (!PreviewSubCameraManager::instance()->mousePressEvent(this, event)) { + if (m_tabletEvent && m_tabletState == Touched) + m_tabletState = StartStroke; return; + } } else if (m_mouseButton == Qt::LeftButton && m_visualSettings.m_doCompare) { if (std::abs(m_pos.x() - width() * m_compareSettings.m_compareX) < 20) { m_compareSettings.m_dragCompareX = true;