xtd - Reference Guide  0.1.2
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
console_key_info.h
Go to the documentation of this file.
1
4#pragma once
5
6#include <iostream>
7#include "console_key.h"
8#include "console_modifiers.h"
9#include "object.h"
10
12namespace xtd {
20 class console_key_info final : public object {
21 public:
25 console_key_info() = default;
26
28 console_key_info(const console_key_info& key_info) noexcept = default;
29 console_key_info& operator=(const console_key_info& key_info) noexcept = default;
30 bool operator==(const console_key_info& key_info) const noexcept {return key_char_ == key_info.key_char_ && key_ == key_info.key_ && modifiers_ == key_info.modifiers_;}
31 bool operator!=(const console_key_info& key_info) const noexcept {return !operator==(key_info);}
33
42 console_key_info(char32_t key_char, console_key key, bool shift, bool alt, bool control) : key_char_(key_char), key_(key) {
43 if (shift == true)
44 modifiers_ = (console_modifiers)((int)modifiers_ | (int)console_modifiers::shift);
45 if (alt == true)
46 modifiers_ = (console_modifiers)((int)modifiers_ | (int)console_modifiers::alt);
47 if (control == true)
48 modifiers_ = (console_modifiers)((int)modifiers_ | (int)console_modifiers::control);
49 }
50
53 console_key key() {return key_;}
54
57 char32_t key_char() {return key_char_;}
58
61 console_modifiers modifiers() {return modifiers_;}
62
63 private:
64 char32_t key_char_ {0};
65 console_key key_ {static_cast<console_key>(0)};
66 console_modifiers modifiers_ {static_cast<console_modifiers>(0)};
67 };
68}
Specifies the standard keys on a console.
Definition console_key_info.h:20
console_key_info()=default
Create a new instance of console_key_info class.
console_key_info(char32_t key_char, console_key key, bool shift, bool alt, bool control)
Initializes a new instance of the console_key_info class using the specified character,...
Definition console_key_info.h:42
console_key key()
Gets the console key represented by the current console_key_info object.
Definition console_key_info.h:53
console_modifiers modifiers()
Gets a bitwise combination of console_modifiers values that specifies one or more modifier keys press...
Definition console_key_info.h:61
char32_t key_char()
Gets the Unicode character represented by the current console_key_info object.
Definition console_key_info.h:57
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:26
Contains xtd::console_key enum class.
Contains xtd::console_modifiers enum class.
console_modifiers
Represents the SHIFT, ALT, and CTRL modifier keys on a keyboard.
Definition console_modifiers.h:16
console_key
Specifies the standard keys on a console.
Definition console_key.h:16
@ shift
The left or right SHIFT modifier key.
@ alt
The left or right ALT modifier key.
@ control
The left or right CTRL modifier key.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition system_report.h:17
Contains xtd::object class.