@@ -836,8 +836,8 @@ struct AlertLayerFix : Modify<AlertLayerFix, CCScene>
836836{
837837 struct Fields
838838 {
839- // its not like the input will change parents...
840- CCLayer* m_outermostInputParent = nullptr ;
839+ std:: size_t m_previous_scene_children_count = 0 ;
840+ CCLayer* m_outermost_input_parent ;
841841 };
842842
843843 static CCScene* create ()
@@ -852,27 +852,28 @@ struct AlertLayerFix : Modify<AlertLayerFix, CCScene>
852852
853853 void onUpdateTick (float )
854854 {
855+ const std::size_t currentChildrenCount = this ->getChildrenCount ();
856+
855857 if (
856858 !g_selectedInput ||
857- !BI::geode::get<bool >(" auto-deselect" ) ||
858- typeinfo_cast<geode::Notification*>(this ->getChildren ()->lastObject ()) ||
859- typeinfo_cast<LoadingCircle*>(this ->getChildren ()->lastObject ())
860- ) {
861- m_fields->m_outermostInputParent = nullptr ;
859+ currentChildrenCount == 1 ||
860+ currentChildrenCount == m_fields->m_previous_scene_children_count
861+ )
862862 return ;
863- }
864863
865- if (!m_fields->m_outermostInputParent )
864+ if (!m_fields->m_outermost_input_parent )
866865 {
867866 CCLayer* outermostInputParent = static_cast <CCLayer*>(g_selectedInput->getParent ());
868867 while (outermostInputParent->getParent () != this )
869868 outermostInputParent = static_cast <CCLayer*>(outermostInputParent->getParent ());
870869
871- m_fields->m_outermostInputParent = outermostInputParent;
870+ m_fields->m_outermost_input_parent = outermostInputParent;
872871 }
873872
874- if (static_cast <CCLayer*>(this ->getChildren ()->lastObject ())->getZOrder () > m_fields->m_outermostInputParent ->getZOrder ())
873+ if (static_cast <CCLayer*>(this ->getChildren ()->lastObject ())->getZOrder () > m_fields->m_outermost_input_parent ->getZOrder ())
875874 g_selectedInput->deselectInput ();
875+
876+ m_fields->m_previous_scene_children_count = currentChildrenCount;
876877 }
877878};
878879
@@ -997,21 +998,24 @@ struct BetterCCEGLView : Modify<BetterCCEGLView, CCEGLView>
997998 {
998999 CCEGLView::onGLFWMouseCallBack (window, button, action, mods);
9991000
1000- if (!g_selectedInput || button != GLFW_MOUSE_BUTTON_1 || action == 1 ) return ;
1001+ if (!g_selectedInput || button != GLFW_MOUSE_BUTTON_1 || action == 2 ) return ;
10011002
1002- CCSize winSize = CCDirector::sharedDirector ()->getWinSize ();
1003- CCPoint mousePos = BI::cocos::getMousePosition ();
1004-
1005- // OpenGL's mouse origin is the bottom left
1006- // CCTouch's mouse origin is top left (because of course it is)
1007- CCTouch touch{};
1008- touch.setTouchInfo (0 , mousePos.x , winSize.height - mousePos.y );
1003+ if (action == 1 )
1004+ {
1005+ CCSize winSize = CCDirector::sharedDirector ()->getWinSize ();
1006+ CCPoint mousePos = BI::cocos::getMousePosition ();
10091007
1010- g_selectedInput->useUpdateBlinkPos (true );
1008+ // OpenGL's mouse origin is the bottom left
1009+ // CCTouch's mouse origin is top left (because of course it is)
1010+ CCTouch touch{};
1011+ touch.setTouchInfo (0 , mousePos.x , winSize.height - mousePos.y );
10111012
1012- // 🥰
1013- g_selectedInput->ccTouchBegan (&touch, nullptr );
1013+ g_selectedInput->useUpdateBlinkPos (true );
10141014
1015- g_selectedInput->useUpdateBlinkPos (false );
1015+ // 🥰
1016+ g_selectedInput->ccTouchBegan (&touch, nullptr );
1017+ }
1018+ else
1019+ g_selectedInput->useUpdateBlinkPos (false );
10161020 }
10171021};
0 commit comments