68 inline bool isCommandDown() const noexcept {
return testFlags (commandModifier); }
78 inline bool isPopupMenu() const noexcept {
return testFlags (popupMenuClickModifier); }
81 inline bool isLeftButtonDown() const noexcept {
return testFlags (leftButtonModifier); }
90 inline bool isMiddleButtonDown() const noexcept {
return testFlags (middleButtonModifier); }
96 inline bool isAnyModifierKeyDown() const noexcept {
return testFlags ((shiftModifier | ctrlModifier | altModifier | commandModifier)); }
99 inline bool isShiftDown() const noexcept {
return testFlags (shiftModifier); }
108 inline bool isCtrlDown() const noexcept {
return testFlags (ctrlModifier); }
111 inline bool isAltDown() const noexcept {
return testFlags (altModifier); }
130 leftButtonModifier = 16,
133 rightButtonModifier = 32,
136 middleButtonModifier = 64,
138 #if JUCE_MAC || JUCE_IOS
144 popupMenuClickModifier = rightButtonModifier | ctrlModifier,
147 commandModifier = ctrlModifier,
151 popupMenuClickModifier = rightButtonModifier,
155 allKeyboardModifiers = shiftModifier | ctrlModifier | altModifier | commandModifier,
158 allMouseButtonModifiers = leftButtonModifier | rightButtonModifier | middleButtonModifier,
161 ctrlAltCommandModifiers = ctrlModifier | altModifier | commandModifier
171 bool operator== (
const ModifierKeys other)
const noexcept {
return flags == other.flags; }
172 bool operator!= (
const ModifierKeys other)
const noexcept {
return flags != other.flags; }
178 [[nodiscard]]
ModifierKeys withoutFlags (
int rawFlagsToClear)
const noexcept {
return ModifierKeys (flags & ~rawFlagsToClear); }
179 [[nodiscard]] ModifierKeys withFlags (
int rawFlagsToSet)
const noexcept {
return ModifierKeys (flags | rawFlagsToSet); }
182 bool testFlags (
int flagsToTest)
const noexcept {
return (flags & flagsToTest) != 0; }
185 int getNumMouseButtonsDown() const noexcept;
197 static
ModifierKeys getCurrentModifiers() noexcept {
return currentModifiers; }
205 static ModifierKeys getCurrentModifiersRealtime() noexcept;
Represents the state of the mouse buttons and modifier keys.
bool isRightButtonDown() const noexcept
Checks whether the flag is set for the right mouse-button.
bool isAltDown() const noexcept
Checks whether the ALT key's flag is set.
bool isAnyMouseButtonDown() const noexcept
Tests for any of the mouse-button flags.
bool testFlags(int flagsToTest) const noexcept
Tests a combination of flags and returns true if any of them are set.
ModifierKeys withOnlyMouseButtons() const noexcept
Returns a copy of only the mouse-button flags.
bool isCtrlDown() const noexcept
Checks whether the CTRL key's flag is set.
bool isLeftButtonDown() const noexcept
Checks whether the flag is set for the left mouse-button.
ModifierKeys(const ModifierKeys &)=default
Creates a copy of another object.
ModifierKeys()=default
Creates a ModifierKeys object with no flags set.
bool isCommandDown() const noexcept
Checks whether the 'command' key flag is set (or 'ctrl' on Windows/Linux).
int getRawFlags() const noexcept
Returns the raw flags for direct testing.
bool isAnyModifierKeyDown() const noexcept
Tests for any of the modifier key flags.
bool isPopupMenu() const noexcept
Checks whether the user is trying to launch a pop-up menu.
bool isShiftDown() const noexcept
Checks whether the shift key's flag is set.
Flags
Flags that represent the different keys.
ModifierKeys withoutMouseButtons() const noexcept
Returns a copy of only the non-mouse flags.