Represents the state of the mouse buttons and modifier keys.
More...
#include <juce_ModifierKeys.h>
|
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...
|
|
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.
- See also
- KeyPress, MouseEvent::mods
◆ Flags
Flags that represent the different keys.
Enumerator |
---|
noModifiers | Indicates no modifier keys.
|
shiftModifier | Shift key flag.
|
ctrlModifier | CTRL key flag.
|
altModifier | ALT key flag.
|
leftButtonModifier | Left mouse button flag.
|
rightButtonModifier | Right mouse button flag.
|
middleButtonModifier | Middle mouse button flag.
|
commandModifier | Command key flag - on windows this is the same as the CTRL key flag.
|
popupMenuClickModifier | Popup menu flag - on windows this is the same as rightButtonModifier, on the Mac it's the same as (rightButtonModifier | ctrlModifier).
|
allKeyboardModifiers | Represents a combination of all the shift, alt, ctrl and command key modifiers.
|
allMouseButtonModifiers | Represents a combination of all the mouse buttons at once.
|
ctrlAltCommandModifiers | Represents a combination of all the alt, ctrl and command key modifiers.
|
◆ ModifierKeys() [1/3]
ModifierKeys::ModifierKeys |
( |
| ) |
|
|
default |
◆ ModifierKeys() [2/3]
ModifierKeys::ModifierKeys |
( |
int | flags | ) |
|
|
noexcept |
◆ ModifierKeys() [3/3]
Creates a copy of another object.
◆ operator=()
Copies this object from another one.
◆ isCommandDown()
bool ModifierKeys::isCommandDown |
( |
| ) |
const |
|
noexcept |
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 cmd key, on Windows/Linux, it's actually checking for the CTRL key.
◆ isPopupMenu()
bool ModifierKeys::isPopupMenu |
( |
| ) |
const |
|
noexcept |
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.
◆ isLeftButtonDown()
bool ModifierKeys::isLeftButtonDown |
( |
| ) |
const |
|
noexcept |
Checks whether the flag is set for the left mouse-button.
◆ isRightButtonDown()
bool ModifierKeys::isRightButtonDown |
( |
| ) |
const |
|
noexcept |
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).
◆ isMiddleButtonDown()
bool ModifierKeys::isMiddleButtonDown |
( |
| ) |
const |
|
noexcept |
◆ isAnyMouseButtonDown()
bool ModifierKeys::isAnyMouseButtonDown |
( |
| ) |
const |
|
noexcept |
Tests for any of the mouse-button flags.
◆ isAnyModifierKeyDown()
bool ModifierKeys::isAnyModifierKeyDown |
( |
| ) |
const |
|
noexcept |
Tests for any of the modifier key flags.
◆ isShiftDown()
bool ModifierKeys::isShiftDown |
( |
| ) |
const |
|
noexcept |
Checks whether the shift key's flag is set.
◆ isCtrlDown()
bool ModifierKeys::isCtrlDown |
( |
| ) |
const |
|
noexcept |
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.
- See also
- isCommandDown, isPopupMenu
◆ isAltDown()
bool ModifierKeys::isAltDown |
( |
| ) |
const |
|
noexcept |
Checks whether the ALT key's flag is set.
◆ withOnlyMouseButtons()
Returns a copy of only the mouse-button flags.
◆ withoutMouseButtons()
Returns a copy of only the non-mouse flags.
◆ operator==()
◆ operator!=()
◆ getRawFlags()
int ModifierKeys::getRawFlags |
( |
| ) |
const |
|
noexcept |
Returns the raw flags for direct testing.
◆ withoutFlags()
◆ withFlags()
◆ testFlags()
bool ModifierKeys::testFlags |
( |
int | flagsToTest | ) |
const |
|
noexcept |
Tests a combination of flags and returns true if any of them are set.
◆ getNumMouseButtonsDown()
int ModifierKeys::getNumMouseButtonsDown |
( |
| ) |
const |
|
noexcept |
Returns the total number of mouse buttons that are down.
◆ getCurrentModifiers()
Creates a ModifierKeys object to represent the last-known state of the keyboard and mouse buttons.
This method is here for backwards compatibility and there's no need to call it anymore, you should use the public currentModifiers member directly.
◆ getCurrentModifiersRealtime()
◆ currentModifiers
This object represents the last-known state of the keyboard and mouse buttons.
The documentation for this class was generated from the following file: