Represents the state of the mouse buttons and modifier keys. More...
#include <juce_ModifierKeys.h>
Public Types | |
enum | Flags { noModifiers = 0, shiftModifier = 1, ctrlModifier = 2, altModifier = 4, leftButtonModifier = 16, rightButtonModifier = 32, middleButtonModifier = 64, commandModifier = 8, popupMenuClickModifier = rightButtonModifier | ctrlModifier, allKeyboardModifiers = shiftModifier | ctrlModifier | altModifier | commandModifier, allMouseButtonModifiers = leftButtonModifier | rightButtonModifier | middleButtonModifier, ctrlAltCommandModifiers = ctrlModifier | altModifier | commandModifier } |
Flags that represent the different keys. More... | |
Public Member Functions | |
ModifierKeys () noexcept | |
Creates a ModifierKeys object with no flags set. More... | |
ModifierKeys (int flags) noexcept | |
Creates a ModifierKeys object from a raw set of flags. More... | |
ModifierKeys (const ModifierKeys &other) noexcept | |
Creates a copy of another object. More... | |
int | getNumMouseButtonsDown () const noexcept |
Returns the total number of mouse buttons that are down. More... | |
int | getRawFlags () const noexcept |
Returns the raw flags for direct testing. More... | |
bool | isAltDown () const noexcept |
Checks whether the ALT key's flag is set. More... | |
bool | isAnyModifierKeyDown () const noexcept |
Tests for any of the modifier key flags. More... | |
bool | isAnyMouseButtonDown () const noexcept |
Tests for any of the mouse-button flags. More... | |
bool | isCommandDown () const noexcept |
Checks whether the 'command' key flag is set (or 'ctrl' on Windows/Linux). More... | |
bool | isCtrlDown () const noexcept |
Checks whether the CTRL key's flag is set. More... | |
bool | isLeftButtonDown () const noexcept |
Checks whether the flag is set for the left mouse-button. More... | |
bool | isMiddleButtonDown () const noexcept |
bool | isPopupMenu () const noexcept |
Checks whether the user is trying to launch a pop-up menu. More... | |
bool | isRightButtonDown () const noexcept |
Checks whether the flag is set for the right mouse-button. More... | |
bool | isShiftDown () const noexcept |
Checks whether the shift key's flag is set. More... | |
bool | operator!= (const ModifierKeys other) const noexcept |
ModifierKeys & | operator= (const ModifierKeys other) noexcept |
Copies this object from another one. More... | |
bool | operator== (const ModifierKeys other) const noexcept |
bool | testFlags (int flagsToTest) const noexcept |
Tests a combination of flags and returns true if any of them are set. More... | |
ModifierKeys | withFlags (int rawFlagsToSet) const noexcept |
ModifierKeys | withOnlyMouseButtons () const noexcept |
Returns a copy of only the mouse-button flags. More... | |
ModifierKeys | withoutFlags (int rawFlagsToClear) const noexcept |
ModifierKeys | withoutMouseButtons () const noexcept |
Returns a copy of only the non-mouse flags. More... | |
Static Public Member Functions | |
static ModifierKeys | getCurrentModifiers () noexcept |
Creates a ModifierKeys object to represent the last-known state of the keyboard and mouse buttons. More... | |
static ModifierKeys | getCurrentModifiersRealtime () noexcept |
Creates a ModifierKeys object to represent the current state of the keyboard and mouse buttons. More... | |
Static Private Member Functions | |
static void | updateCurrentModifiers () noexcept |
Private Attributes | |
int | flags |
Static Private Attributes | |
static ModifierKeys | currentModifiers |
Friends | |
class | ComponentPeer |
class | MouseInputSource |
class | MouseInputSourceInternal |
Represents the state of the mouse buttons and modifier keys.
This is used both by mouse events and by KeyPress objects to describe the state of keys such as shift, control, alt, etc.
enum ModifierKeys::Flags |
Flags that represent the different keys.
|
noexcept |
Creates a ModifierKeys object with no flags set.
|
noexcept |
Creates a ModifierKeys object from a raw set of flags.
flags | to represent the keys that are down |
|
noexcept |
Creates a copy of another object.
|
staticnoexcept |
Creates a ModifierKeys object to represent the last-known state of the keyboard and mouse buttons.
Referenced by FakeMouseMoveGenerator::timerCallback().
|
staticnoexcept |
Creates a ModifierKeys object to represent the current state of the keyboard and mouse buttons.
This isn't often needed and isn't recommended, but will actively check all the mouse and key states rather than just returning their last-known state like getCurrentModifiers() does.
This is only needed in special circumstances for up-to-date modifier information at times when the app's event loop isn't running normally.
Another reason to avoid this method is that it's not stateless, and calling it may update the value returned by getCurrentModifiers(), which could cause subtle changes in the behaviour of some components.
|
noexcept |
Returns the total number of mouse buttons that are down.
|
inlinenoexcept |
Returns the raw flags for direct testing.
|
inlinenoexcept |
Checks whether the ALT key's flag is set.
Referenced by LassoComponent< SelectableItemType >::dragLasso(), and TextEditorKeyMapper< CallbackClass >::invokeKeyFunction().
|
inlinenoexcept |
Tests for any of the modifier key flags.
|
inlinenoexcept |
Tests for any of the mouse-button flags.
Referenced by FakeMouseMoveGenerator::timerCallback().
|
inlinenoexcept |
Checks whether the 'command' key flag is set (or 'ctrl' on Windows/Linux).
This is a platform-agnostic way of checking for the operating system's preferred command-key modifier - so on the Mac it tests for the Apple key, on Windows/Linux, it's actually checking for the CTRL key.
Referenced by SelectedItemSet< SelectableItemType >::addToSelectionBasedOnModifiers(), LassoComponent< SelectableItemType >::dragLasso(), and TextEditorKeyMapper< CallbackClass >::invokeKeyFunction().
|
inlinenoexcept |
Checks whether the CTRL key's flag is set.
Remember that it's better to use the platform-agnostic routines to test for command-key and popup-menu modifiers.
Referenced by TextEditorKeyMapper< CallbackClass >::invokeKeyFunction().
|
inlinenoexcept |
Checks whether the flag is set for the left mouse-button.
|
inlinenoexcept |
|
inlinenoexcept |
Checks whether the user is trying to launch a pop-up menu.
This checks for platform-specific modifiers that might indicate that the user is following the operating system's normal method of showing a pop-up menu.
So on Windows/Linux, this method is really testing for a right-click. On the Mac, it tests for either the CTRL key being down, or a right-click.
Referenced by SelectedItemSet< SelectableItemType >::addToSelectionOnMouseDown().
|
inlinenoexcept |
Checks whether the flag is set for the right mouse-button.
Note that for detecting popup-menu clicks, you should be using isPopupMenu() instead, as this is platform-independent (and makes your code more explanatory too).
|
inlinenoexcept |
Checks whether the shift key's flag is set.
Referenced by SelectedItemSet< SelectableItemType >::addToSelectionBasedOnModifiers(), LassoComponent< SelectableItemType >::dragLasso(), and TextEditorKeyMapper< CallbackClass >::invokeKeyFunction().
|
inlinenoexcept |
References flags.
|
noexcept |
Copies this object from another one.
|
inlinenoexcept |
References flags.
|
inlinenoexcept |
Tests a combination of flags and returns true if any of them are set.
|
staticprivatenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Returns a copy of only the mouse-button flags.
|
inlinenoexcept |
|
inlinenoexcept |
Returns a copy of only the non-mouse flags.
|
friend |
|
friend |
|
friend |
|
staticprivate |
|
private |
Referenced by operator!=(), and operator==().