50 if (
mappings.getUnchecked(
i)->commandID == commandID)
51 return mappings.getUnchecked (
i)->keypresses;
69 if (
mappings.getUnchecked(
i)->commandID == commandID)
71 mappings.getUnchecked(
i)->keypresses.insert (insertIndex, newKeyPress);
135 if (
mappings.getUnchecked(
i)->commandID == commandID)
167 if (
mappings.getUnchecked(
i)->commandID == commandID)
169 mappings.getUnchecked(
i)->keypresses.remove (keyPressIndex);
180 if (
mappings.getUnchecked(
i)->keypresses.contains (keyPress))
181 return mappings.getUnchecked(
i)->commandID;
189 if (
mappings.getUnchecked(
i)->commandID == commandID)
190 return mappings.getUnchecked(
i)->keypresses.contains (keyPress);
197 const bool isKeyDown,
198 const int millisecsSinceKeyPressed,
199 Component*
const originatingComponent)
const
204 info.isKeyDown = isKeyDown;
206 info.millisecsSinceKeyPressed = millisecsSinceKeyPressed;
207 info.originatingComponent = originatingComponent;
232 const CommandID commandId = map->getStringAttribute (
"commandId").getHexValue32();
238 if (map->hasTagName (
"MAPPING"))
242 else if (map->hasTagName (
"UNMAPPING"))
245 if (
m->commandID == commandId)
246 m->keypresses.removeAllInstancesOf (
key);
259 std::unique_ptr<KeyPressMappingSet> defaultSet;
261 if (saveDifferencesFromDefaultSet)
263 defaultSet = std::make_unique<KeyPressMappingSet> (
commandManager);
264 defaultSet->resetToDefaultMappings();
267 auto doc = std::make_unique<XmlElement> (
"KEYMAPPINGS");
269 doc->setAttribute (
"basedOnDefaults", saveDifferencesFromDefaultSet);
275 for (
int j = 0;
j < cm.keypresses.size(); ++
j)
277 if (defaultSet ==
nullptr
278 || ! defaultSet->containsMapping (cm.commandID, cm.keypresses.getReference (
j)))
280 auto map = doc->createNewChildElement (
"MAPPING");
283 map->setAttribute (
"description",
commandManager.getDescriptionOfCommand (cm.commandID));
284 map->setAttribute (
"key", cm.keypresses.getReference (
j).getTextDescription());
289 if (defaultSet !=
nullptr)
291 for (
int i = 0;
i < defaultSet->mappings.size(); ++
i)
293 auto& cm = *defaultSet->mappings.getUnchecked(
i);
295 for (
int j = 0;
j < cm.keypresses.size(); ++
j)
299 auto map = doc->createNewChildElement (
"UNMAPPING");
302 map->setAttribute (
"description",
commandManager.getDescriptionOfCommand (cm.commandID));
303 map->setAttribute (
"key", cm.keypresses.getReference (
j).getTextDescription());
315 bool commandWasDisabled =
false;
337 commandWasDisabled =
true;
344 if (originatingComponent !=
nullptr && commandWasDisabled)
364 const bool isDown =
key.isCurrentlyDown();
366 int keyPressEntryIndex = 0;
367 bool wasDown =
false;
373 keyPressEntryIndex =
k;
380 if (isDown != wasDown)
388 k->timeWhenPressed = now;
394 const uint32 pressTime =
keysDown.getUnchecked (keyPressEntryIndex)->timeWhenPressed;
397 millisecs = (
int) (now - pressTime);
399 keysDown.remove (keyPressEntryIndex);
414 if (focusedComponent !=
nullptr)
Definition juce_ApplicationCommandManager.h:88
Definition juce_Array.h:56
void sendChangeMessage()
Definition juce_ChangeBroadcaster.cpp:65
ChangeBroadcaster() noexcept
Definition juce_ChangeBroadcaster.cpp:26
static bool isUpperCase(juce_wchar character) noexcept
Definition juce_CharacterFunctions.cpp:38
Definition juce_Component.h:36
virtual bool keyStateChanged(bool isKeyDown)
Definition juce_Component.cpp:3231
LookAndFeel & getLookAndFeel() const noexcept
Definition juce_Component.cpp:2173
static Desktop &JUCE_CALLTYPE getInstance()
Definition juce_Desktop.cpp:50
Definition juce_Desktop.h:39
Definition juce_KeyListener.h:41
Definition juce_KeyPress.h:40
juce_wchar getTextCharacter() const noexcept
Definition juce_KeyPress.h:122
bool isValid() const noexcept
Definition juce_KeyPress.h:102
ModifierKeys getModifiers() const noexcept
Definition juce_KeyPress.h:115
static KeyPress createFromDescription(const String &textVersion)
Definition juce_KeyPress.cpp:174
Definition juce_KeyPressMappingSet.h:89
ApplicationCommandManager & commandManager
Definition juce_KeyPressMappingSet.h:218
void addKeyPress(CommandID commandID, const KeyPress &newKeyPress, int insertIndex=-1)
Definition juce_KeyPressMappingSet.cpp:56
void resetToDefaultMapping(CommandID commandID)
Definition juce_KeyPressMappingSet.cpp:114
Array< KeyPress > getKeyPressesAssignedToCommand(CommandID commandID) const
Definition juce_KeyPressMappingSet.cpp:47
bool containsMapping(CommandID commandID, const KeyPress &keyPress) const noexcept
Definition juce_KeyPressMappingSet.cpp:186
void removeKeyPress(CommandID commandID, int keyPressIndex)
Definition juce_KeyPressMappingSet.cpp:163
~KeyPressMappingSet() override
Definition juce_KeyPressMappingSet.cpp:41
void globalFocusChanged(Component *) override
Definition juce_KeyPressMappingSet.cpp:412
void clearAllKeyPresses()
Definition juce_KeyPressMappingSet.cpp:122
void resetToDefaultMappings()
Definition juce_KeyPressMappingSet.cpp:104
OwnedArray< KeyPressTime > keysDown
Definition juce_KeyPressMappingSet.h:235
CommandID findCommandForKeyPress(const KeyPress &keyPress) const noexcept
Definition juce_KeyPressMappingSet.cpp:177
bool keyPressed(const KeyPress &, Component *) override
Definition juce_KeyPressMappingSet.cpp:313
KeyPressMappingSet(ApplicationCommandManager &)
Definition juce_KeyPressMappingSet.cpp:29
void invokeCommand(const CommandID, const KeyPress &, const bool isKeyDown, const int millisecsSinceKeyPressed, Component *originator) const
Definition juce_KeyPressMappingSet.cpp:195
bool keyStateChanged(bool isKeyDown, Component *) override
Definition juce_KeyPressMappingSet.cpp:350
bool restoreFromXml(const XmlElement &xmlVersion)
Definition juce_KeyPressMappingSet.cpp:213
std::unique_ptr< XmlElement > createXml(bool saveDifferencesFromDefaultSet) const
Definition juce_KeyPressMappingSet.cpp:257
OwnedArray< CommandMapping > mappings
Definition juce_KeyPressMappingSet.h:227
virtual void playAlertSound()
Definition juce_linux_Windowing.cpp:809
bool isShiftDown() const noexcept
Definition juce_ModifierKeys.h:99
static String toHexString(IntegerType number)
Definition juce_String.h:1097
static uint32 getMillisecondCounter() noexcept
Definition juce_Time.cpp:241
Definition juce_XmlElement.h:83
bool getBoolAttribute(StringRef attributeName, bool defaultReturnValue=false) const
Definition juce_XmlElement.cpp:587
bool hasTagName(StringRef possibleTagName) const noexcept
Definition juce_XmlElement.cpp:470
Iterator< GetNextElement > getChildIterator() const
Definition juce_XmlElement.h:715
unsigned * m
Definition inflate.c:1559
register unsigned k
Definition inflate.c:946
register unsigned j
Definition inflate.c:1576
register unsigned i
Definition inflate.c:1575
struct backing_store_struct * info
Definition jmemsys.h:183
Definition carla_juce.cpp:31
static void addKeyPresses(KeyPressMappingSet &set, const ApplicationCommandInfo *const ci)
Definition juce_KeyPressMappingSet.cpp:98
unsigned int uint32
Definition juce_MathsFunctions.h:45
int CommandID
Definition juce_ApplicationCommandID.h:37
Definition juce_ApplicationCommandInfo.h:45
Array< KeyPress > defaultKeypresses
Definition juce_ApplicationCommandInfo.h:127
CommandID commandID
Definition juce_ApplicationCommandInfo.h:87
@ wantsKeyUpDownCallbacks
Definition juce_ApplicationCommandInfo.h:163
@ isDisabled
Definition juce_ApplicationCommandInfo.h:146
Definition juce_ApplicationCommandTarget.h:61
@ fromKeyPress
Definition juce_ApplicationCommandTarget.h:79
Definition juce_KeyPressMappingSet.h:221
bool wantsKeyUpDownCallbacks
Definition juce_KeyPressMappingSet.h:224
CommandID commandID
Definition juce_KeyPressMappingSet.h:222
Array< KeyPress > keypresses
Definition juce_KeyPressMappingSet.h:223
Definition juce_KeyPressMappingSet.h:230
ZCONST char * key
Definition crypt.c:587
typedef int(UZ_EXP MsgFn)()