Skip to content

Commit

Permalink
fix Command + A crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaghettDev committed Dec 1, 2024
1 parent ba0d385 commit 0b468f9
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,11 @@ void keyDownExec(EAGLView* self, SEL sel, NSEvent* event) {

if (
![event isARepeat] &&
!BI::platform::keyDown(BI::PlatformKey::LEFT_CONTROL, event) &&
BI::platform::keyDown(BI::PlatformKey::LEFT_SHIFT, event)
BI::platform::keyDown(BI::PlatformKey::LEFT_CONTROL, event) &&
!BI::platform::keyDown(BI::PlatformKey::LEFT_SHIFT, event)
) {
switch ([event keyCode])
{
case kVK_Delete:
case kVK_ForwardDelete:
return g_selectedInput->onDelete(true, [event keyCode] == kVK_ForwardDelete);

case 'a': case 'A':
return g_selectedInput->highlightFromToPos(0, -1);

Expand All @@ -117,6 +113,10 @@ void keyDownExec(EAGLView* self, SEL sel, NSEvent* event) {
case 'x': case 'X':
return g_selectedInput->onCut();

case kVK_Delete:
case kVK_ForwardDelete:
return g_selectedInput->onDelete(true, [event keyCode] == kVK_ForwardDelete);

default:
break;
}
Expand Down Expand Up @@ -152,12 +152,10 @@ void keyDownExec(EAGLView* self, SEL sel, NSEvent* event) {
void keyUpExec(EAGLView* self, SEL sel, NSEvent* event) {
if (!g_selectedInput)
return keyUpExecOIMP(self, sel, event);

geode::log::debug("key released ({})", [event keyCode]);
}


// TODO: move to hooking mouseDownExec
// TODO: move to hooking mouseDownExec/mouseUpExec
// handles mouse clicks
struct BetterTouchDispatcher : geode::Modify<BetterTouchDispatcher, cocos2d::CCTouchDispatcher>
{
Expand All @@ -167,8 +165,6 @@ void touches(cocos2d::CCSet* touches, cocos2d::CCEvent* event, unsigned int type
if (!g_selectedInput)
return cocos2d::CCTouchDispatcher::touches(touches, event, type);

geode::log::debug("button clicked");

auto* touch = static_cast<cocos2d::CCTouch*>(touches->anyObject());
const auto touchPos = touch->getLocation();

Expand Down

0 comments on commit 0b468f9

Please sign in to comment.