Skip to content

Commit 9afcd37

Browse files
committed
add ability to cancel thing with esc
1 parent fc64742 commit 9afcd37

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/DevTools.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,7 @@ bool DevTools::isHoverSelectEnabled() const {
268268
void DevTools::consumeNodeHoverTouch() {
269269
m_nodeHoverSelectConsumeTouch = true;
270270
}
271+
272+
void DevTools::cancelHoverSelect() {
273+
m_nodeHoverSelectEnabled = false;
274+
}

src/DevTools.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class DevTools {
9494
bool shouldOrderChildren() const;
9595
bool isHoverSelectEnabled() const;
9696
void consumeNodeHoverTouch();
97+
void cancelHoverSelect();
9798

9899
CCNode* getSelectedNode() const;
99100
void selectNode(CCNode* node);

src/main.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@ class $modify(CCNode) {
2222
// todo: use shortcuts api once Geode has those
2323
class $modify(CCKeyboardDispatcher) {
2424
bool dispatchKeyboardMSG(enumKeyCodes key, bool down, bool arr) {
25+
auto dt = DevTools::get();
26+
2527
if (down && (key == KEY_F11 GEODE_MACOS(|| key == KEY_F10))) {
26-
DevTools::get()->toggle();
28+
dt->toggle();
29+
return true;
30+
} else if (down && key == KEY_Escape && dt->isHoverSelectEnabled()) {
31+
dt->cancelHoverSelect();
2732
return true;
2833
}
34+
2935
return CCKeyboardDispatcher::dispatchKeyboardMSG(key, down, arr);
3036
}
3137
};
@@ -51,7 +57,7 @@ class $modify(CCDirector) {
5157
if (!DevTools::get()->shouldUseGDWindow()) {
5258
return CCDirector::drawScene();
5359
}
54-
60+
5561
DevTools::get()->setup();
5662

5763
static GLRenderCtx* gdTexture = nullptr;

0 commit comments

Comments
 (0)