Skip to content

Commit cb52c57

Browse files
committed
Update actionMap.cpp
cross platform actionmapping for popupmenus
1 parent cf8abee commit cb52c57

1 file changed

Lines changed: 46 additions & 17 deletions

File tree

Engine/source/sim/actionMap.cpp

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -466,23 +466,52 @@ bool ActionMap::createEventDescriptor(const char* pEventString, EventDescriptor*
466466
pObjectString = pSpace + 1;
467467
pSpace[0] = '\0';
468468

469-
char* pModifier = dStrtok(copyBuffer, "-");
470-
while (pModifier != NULL) {
471-
if (dStricmp(pModifier, "shift") == 0) {
472-
pDescriptor->flags |= SI_SHIFT;
473-
} else if (dStricmp(pModifier, "ctrl") == 0) {
474-
pDescriptor->flags |= SI_CTRL;
475-
} else if (dStricmp(pModifier, "alt") == 0) {
476-
pDescriptor->flags |= SI_ALT;
477-
} else if (dStricmp(pModifier, "cmd") == 0) {
478-
pDescriptor->flags |= SI_ALT;
479-
} else if (dStricmp(pModifier, "opt") == 0) {
480-
pDescriptor->flags |= SI_MAC_OPT;
481-
}
482-
483-
pModifier = dStrtok(NULL, "-");
484-
}
485-
} else {
469+
char* pModifier = dStrtok(copyBuffer, "-");
470+
while (pModifier != NULL)
471+
{
472+
#if defined(TORQUE_OS_MAC)
473+
if (dStricmp(pModifier, "ctrl") == 0 || dStricmp(pModifier, "cmd") == 0)
474+
{
475+
pDescriptor->flags |= SI_ALT; // On Mac, map Ctrl/Cmd to the standard Mac command key
476+
}
477+
else if (dStricmp(pModifier, "shift") == 0)
478+
{
479+
pDescriptor->flags |= SI_SHIFT;
480+
}
481+
else if (dStricmp(pModifier, "alt") == 0)
482+
{
483+
if (pDescriptor->flags & SI_ALT)
484+
pDescriptor->flags |= SI_MAC_OPT;
485+
else
486+
pDescriptor->flags |= SI_ALT;
487+
}
488+
else if (dStricmp(pModifier, "opt") == 0)
489+
{
490+
pDescriptor->flags |= SI_MAC_OPT;
491+
}
492+
#else
493+
if (dStricmp(pModifier, "ctrl") == 0)
494+
{
495+
pDescriptor->flags |= SI_CTRL;
496+
}
497+
else if (dStricmp(pModifier, "shift") == 0)
498+
{
499+
pDescriptor->flags |= SI_SHIFT;
500+
}
501+
else if (dStricmp(pModifier, "alt") == 0 || dStricmp(pModifier, "opt") == 0)
502+
{
503+
pDescriptor->flags |= SI_ALT;
504+
}
505+
else if (dStricmp(pModifier, "cmd") == 0)
506+
{
507+
pDescriptor->flags |= SI_ALT; // Optional: some Windows scripts might use 'cmd'
508+
}
509+
#endif
510+
pModifier = dStrtok(NULL, "-");
511+
}
512+
}
513+
else
514+
{
486515
// No.
487516
pDescriptor->flags = 0;
488517
pObjectString = copyBuffer;

0 commit comments

Comments
 (0)