LuciadCPillar 2024.0.08
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
luciad::ModifierKeys Struct Reference

Utility class that contains the combination of the modifier keys pressed. More...

#include <luciad/input/ModifierKeys.h>

Public Member Functions

constexpr ModifierKeys (size_t keys)
 Creates a new instance. More...
 
constexpr size_t getKeys () const
 Returns the combined pressed modifier keys. More...
 
constexpr bool hasFlag (ModifierKeys keys) const
 Returns if the specified modifier keys are pressed. More...
 
bool operator!= (const ModifierKeys &other) const
 
constexpr ModifierKeys operator& (const ModifierKeys &other) const
 
constexpr ModifierKeysoperator&= (const ModifierKeys &other)
 
constexpr ModifierKeysoperator= (const ModifierKeys &other)=default
 
bool operator== (const ModifierKeys &other) const
 
constexpr ModifierKeys operator^ (const ModifierKeys &other) const
 
constexpr ModifierKeysoperator^= (const ModifierKeys &other)
 
constexpr ModifierKeys operator| (const ModifierKeys &other) const
 
constexpr ModifierKeysoperator|= (const ModifierKeys &other)
 
constexpr ModifierKeys operator~ () const
 

Static Public Member Functions

static const ModifierKeysalt ()
 A ModifierKeys instance that represents the Alt modifier key. More...
 
static const ModifierKeysctrl ()
 A ModifierKeys instance that represents the Ctrl modifier key. More...
 
static const ModifierKeysnone ()
 A ModifierKeys instance that represents no modifier keys. More...
 
static const ModifierKeysshift ()
 A ModifierKeys instance that represents the Shift modifier key. More...
 

Detailed Description

Utility class that contains the combination of the modifier keys pressed.

The modifiers keys are mapped to the following values:

  • None => 0
  • Alt => 1
  • Ctrl => 2
  • Shift => 4
Note
Don't use the hasFlag method if you want to check that there are no modifiers set, instead do
bool checkNone = shift == ModifierKeys::none();
EXPECT_FALSE(checkNone);
checkNone = none == ModifierKeys::none();
EXPECT_TRUE(checkNone);
static const ModifierKeys & shift()
A ModifierKeys instance that represents the Shift modifier key.
static const ModifierKeys & none()
A ModifierKeys instance that represents no modifier keys.

An example usage is:

auto ctrlAlt = ctrl | alt;
bool isNone = ctrlAlt == ModifierKeys::none(); // False
bool isAlt = ctrlAlt.hasFlag(ModifierKeys::alt()); // True
bool isCtrlAlt = ctrlAlt == (ModifierKeys::alt() | ModifierKeys::ctrl()); // True
static const ModifierKeys & alt()
A ModifierKeys instance that represents the Alt modifier key.
static const ModifierKeys & ctrl()
A ModifierKeys instance that represents the Ctrl modifier key.
See also
luciad::KeyCode for the available key codes to use in conjunction with this class.
Since
2020.1

Constructor & Destructor Documentation

◆ ModifierKeys()

constexpr luciad::ModifierKeys::ModifierKeys ( size_t  keys)
inlineexplicitconstexpr

Creates a new instance.

Parameters
keysthe bits that represent the modifier keys.

Member Function Documentation

◆ alt()

static const ModifierKeys & luciad::ModifierKeys::alt ( )
static

A ModifierKeys instance that represents the Alt modifier key.

◆ ctrl()

static const ModifierKeys & luciad::ModifierKeys::ctrl ( )
static

A ModifierKeys instance that represents the Ctrl modifier key.

◆ getKeys()

constexpr size_t luciad::ModifierKeys::getKeys ( ) const
inlineconstexpr

Returns the combined pressed modifier keys.

Returns
the combined pressed modifier keys.

◆ hasFlag()

constexpr bool luciad::ModifierKeys::hasFlag ( ModifierKeys  keys) const
inlineconstexpr

Returns if the specified modifier keys are pressed.

Parameters
keys
Returns
if the keys are pressed

◆ none()

static const ModifierKeys & luciad::ModifierKeys::none ( )
static

A ModifierKeys instance that represents no modifier keys.

◆ operator!=()

bool luciad::ModifierKeys::operator!= ( const ModifierKeys other) const
inline

◆ operator&()

constexpr ModifierKeys luciad::ModifierKeys::operator& ( const ModifierKeys other) const
inlineconstexpr

◆ operator&=()

constexpr ModifierKeys & luciad::ModifierKeys::operator&= ( const ModifierKeys other)
inlineconstexpr

◆ operator=()

constexpr ModifierKeys & luciad::ModifierKeys::operator= ( const ModifierKeys other)
constexprdefault

◆ operator==()

bool luciad::ModifierKeys::operator== ( const ModifierKeys other) const
inline

◆ operator^()

constexpr ModifierKeys luciad::ModifierKeys::operator^ ( const ModifierKeys other) const
inlineconstexpr

◆ operator^=()

constexpr ModifierKeys & luciad::ModifierKeys::operator^= ( const ModifierKeys other)
inlineconstexpr

◆ operator|()

constexpr ModifierKeys luciad::ModifierKeys::operator| ( const ModifierKeys other) const
inlineconstexpr

◆ operator|=()

constexpr ModifierKeys & luciad::ModifierKeys::operator|= ( const ModifierKeys other)
inlineconstexpr

◆ operator~()

constexpr ModifierKeys luciad::ModifierKeys::operator~ ( ) const
inlineconstexpr

◆ shift()

static const ModifierKeys & luciad::ModifierKeys::shift ( )
static

A ModifierKeys instance that represents the Shift modifier key.