xtd 0.2.0
Loading...
Searching...
No Matches
key_event_args.h
Go to the documentation of this file.
1
4#pragma once
5#include "keys.h"
6#include <xtd/event_args>
7
9namespace xtd {
11 namespace forms {
23 class key_event_args : public event_args {
24 public:
26
29 key_event_args() = default;
34
37 key_event_args& operator =(const xtd::forms::key_event_args& key_event_args) = default;
39
41
45 bool alt() const noexcept {return (key_data_ & xtd::forms::keys::alt) == keys::alt;}
46
49 bool command() const noexcept {return (key_data_ & xtd::forms::keys::command) == keys::command;}
50
53 bool control() const noexcept {return (key_data_ & xtd::forms::keys::control) == keys::control;}
54
58 bool handled() const noexcept {return handled_;}
62 void handled(bool handled) {handled_ = handled;}
63
66 keys key_code() const noexcept {return key_data_ & xtd::forms::keys::key_code;}
67
71 keys key_data() const noexcept {return key_data_;}
72
75 int32 key_value() const noexcept {return static_cast<int32>(key_data_) & 0xFFFF;}
76
79 keys modifiers() const noexcept {return key_data_ & xtd::forms::keys::modifiers;}
80
83 bool shift() const noexcept {return (key_data_ & xtd::forms::keys::shift) == keys::shift;}
84
89 bool suppress_key_press() const noexcept {return suppress_key_press_;}
95 suppress_key_press_ = suppress_key_press;
96 if (suppress_key_press) handled(true);
97 }
99
100 private:
102 bool handled_ = false;
103 bool suppress_key_press_ = false;
104 };
105 }
106}
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.h:18
Provides data for the xtd::forms::control::key_down or xtd::forms::control::key_up event.
Definition key_event_args.h:23
key_event_args(xtd::forms::keys key_data)
Initializes a new instance of the key_event_args class.
Definition key_event_args.h:32
keys modifiers() const noexcept
Gets the modifier flags for a xtd::forms::control::key_down or xtd::forms::control::key_up event....
Definition key_event_args.h:79
bool control() const noexcept
Gets a value indicating whether the CTRL key was pressed.
Definition key_event_args.h:53
bool handled() const noexcept
Gets a value indicating whether the event was handled.
Definition key_event_args.h:58
void handled(bool handled)
Sets a value indicating whether the event was handled.
Definition key_event_args.h:62
int32 key_value() const noexcept
Gets the keyboard value for a xtd::forms::control::key_down or xtd::forms::control::key_up event.
Definition key_event_args.h:75
bool shift() const noexcept
Gets a value indicating whether the SHIFT key was pressed.
Definition key_event_args.h:83
bool command() const noexcept
Gets a value indicating whether the CMD key was pressed.
Definition key_event_args.h:49
bool suppress_key_press() const noexcept
Gets a value indicating whether the key event should be passed on to the underlying control.
Definition key_event_args.h:89
keys key_code() const noexcept
Gets the keyboard code for a xtd::forms::control::key_down or xtd::forms::control::key_up event.
Definition key_event_args.h:66
bool alt() const noexcept
Gets a value indicating whether the ALT key was pressed.
Definition key_event_args.h:45
key_event_args()=default
Initializes a new instance of the key_event_args class.
void suppress_key_press(bool suppress_key_press)
Sets a value indicating whether the key event should be passed on to the underlying control.
Definition key_event_args.h:94
keys key_data() const noexcept
Gets the key data for a xtd::forms::control::key_down or xtd::forms::control::key_up event.
Definition key_event_args.h:71
int_least32_t int32
Represents a 32-bit signed integer.
Definition types.h:131
keys
Specifies key codes and modifiers.
Definition keys.h:74
@ command
The CMD modifier key.
@ shift
The SHIFt modifier key.
@ none
No key pressed.
@ alt
The ALT modifier key.
@ key_code
The bitmask to extract a key code from a key value.
@ modifiers
The bitmask to extract modifiers from a key value.
@ control
The CTRL modifier key.
Contains xtd::forms::keys enum class.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10