File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,12 @@ struct MouseInfo::Impl {
1313 bool down = false ;
1414 Vec2 mousePos;
1515 VirtualMouseCursor* virtualCursor = nullptr ;
16+ bool pressedBlocked = false ;
1617
1718 bool getPressed () const {
19+ if (pressedBlocked) {
20+ return false ;
21+ }
1822 if (virtualCursor) {
1923 return virtualCursor->pressed ();
2024 }
@@ -43,13 +47,15 @@ void MouseInfo::setMousePos(Vec2 mousePos) {
4347 impls.resize (1 );
4448 }
4549 impls[0 ].enabled = true ;
50+ impls[0 ].pressedBlocked = false ;
4651 impls[0 ].mousePos = mousePos;
4752
4853 if (auto virtualCursor = getJob<VirtualMouseCursor>()) {
4954 if (impls.size () < 2 ) {
5055 impls.resize (2 );
5156 }
5257 impls[1 ].enabled = true ;
58+ impls[1 ].pressedBlocked = false ;
5359 impls[1 ].mousePos = virtualCursor->getPosition ();
5460 impls[1 ].virtualCursor = virtualCursor.get ();
5561 }
@@ -71,6 +77,10 @@ bool MouseInfo::Down::pressedAgain() const {
7177 return parent->getPressed ();
7278}
7379
80+ void MouseInfo::Down::blockPressedImmediately () {
81+ parent->pressedBlocked = true ;
82+ }
83+
7484MouseInfo::Down::Down (MouseInfo::Impl& parent, Vec2 objectPos)
7585: parent(&parent), startReference(parent.mousePos - objectPos) {
7686 parent.down = true ;
Original file line number Diff line number Diff line change @@ -52,6 +52,10 @@ class MouseInfo {
5252 // / again if the mouse is pressed again
5353 bool pressedAgain () const ;
5454
55+ // / Calling this will cause pressedAgain() to return false directly, not waiting for the
56+ // / next frame or anything:
57+ void blockPressedImmediately ();
58+
5559 Down (MouseInfo::Impl&, Vec2 objectPos);
5660 Down (const Down&) = delete ;
5761 Down (Down&&) noexcept ;
You can’t perform that action at this time.
0 commit comments