JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_KeyPressMappingSet.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
86class JUCE_API KeyPressMappingSet : public KeyListener,
87 public ChangeBroadcaster,
89{
90public:
91 //==============================================================================
105
108
110 ~KeyPressMappingSet() override;
111
112 //==============================================================================
113 ApplicationCommandManager& getCommandManager() const noexcept { return commandManager; }
114
115 //==============================================================================
120 Array<KeyPress> getKeyPressesAssignedToCommand (CommandID commandID) const;
121
135 void addKeyPress (CommandID commandID,
136 const KeyPress& newKeyPress,
137 int insertIndex = -1);
138
142 void resetToDefaultMappings();
143
147 void resetToDefaultMapping (CommandID commandID);
148
150 void clearAllKeyPresses();
151
153 void clearAllKeyPresses (CommandID commandID);
154
159 void removeKeyPress (CommandID commandID, int keyPressIndex);
160
162 void removeKeyPress (const KeyPress& keypress);
163
165 bool containsMapping (CommandID commandID, const KeyPress& keyPress) const noexcept;
166
167 //==============================================================================
171 CommandID findCommandForKeyPress (const KeyPress& keyPress) const noexcept;
172
173 //==============================================================================
189 bool restoreFromXml (const XmlElement& xmlVersion);
190
206 std::unique_ptr<XmlElement> createXml (bool saveDifferencesFromDefaultSet) const;
207
208 //==============================================================================
210 bool keyPressed (const KeyPress&, Component*) override;
212 bool keyStateChanged (bool isKeyDown, Component*) override;
214 void globalFocusChanged (Component*) override;
215
216private:
217 //==============================================================================
218 ApplicationCommandManager& commandManager;
219
220 struct CommandMapping
221 {
222 CommandID commandID;
223 Array<KeyPress> keypresses;
224 bool wantsKeyUpDownCallbacks;
225 };
226
228
229 struct KeyPressTime
230 {
231 KeyPress key;
232 uint32 timeWhenPressed;
233 };
234
236
237 void invokeCommand (CommandID, const KeyPress&, bool isKeyDown,
238 int millisecsSinceKeyPressed, Component* originator) const;
239
240 KeyPressMappingSet& operator= (const KeyPressMappingSet&);
242};
243
244} // namespace juce
One of these objects holds a list of all the commands your app can perform, and despatches these comm...
Holds a resizable array of primitive or copy-by-value objects.
Definition juce_Array.h:56
Holds a list of ChangeListeners, and sends messages to them when instructed.
The base class for all JUCE user-interface objects.
Classes can implement this interface and register themselves with the Desktop class to receive callba...
Receives callbacks when keys are pressed.
Manages and edits a list of keypresses, which it uses to invoke the appropriate command in an Applica...
Represents a key press, including any modifier keys that are needed.
An array designed for holding objects.
Used to build a tree of elements representing an XML document.
#define JUCE_LEAK_DETECTOR(OwnerClass)
This macro lets you embed a leak-detecting object inside a class.
JUCE Namespace.
unsigned int uint32
A platform-independent 32-bit unsigned integer type.
int CommandID
A type used to hold the unique ID for an application command.