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 {
25 class key_event_args : public event_args {
26 public:
28
31 key_event_args() = default;
36
39 key_event_args& operator =(const xtd::forms::key_event_args& key_event_args) = default;
41
43
47 bool alt() const noexcept {return (key_data_ & xtd::forms::keys::alt) == keys::alt;}
48
51 bool command() const noexcept {return (key_data_ & xtd::forms::keys::command) == keys::command;}
52
55 bool control() const noexcept {return (key_data_ & xtd::forms::keys::control) == keys::control;}
56
60 bool handled() const noexcept {return handled_;}
64 void handled(bool handled) {handled_ = handled;}
65
68 keys key_code() const noexcept {return key_data_ & xtd::forms::keys::key_code;}
69
73 keys key_data() const noexcept {return key_data_;}
74
77 int32 key_value() const noexcept {return static_cast<int32>(key_data_) & 0xFFFF;}
78
81 keys modifiers() const noexcept {return key_data_ & xtd::forms::keys::modifiers;}
82
85 bool shift() const noexcept {return (key_data_ & xtd::forms::keys::shift) == keys::shift;}
86
91 bool suppress_key_press() const noexcept {return suppress_key_press_;}
97 suppress_key_press_ = suppress_key_press;
98 if (suppress_key_press) handled(true);
99 }
101
102 private:
104 bool handled_ = false;
105 bool suppress_key_press_ = false;
106 };
107 }
108}
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:25
key_event_args(xtd::forms::keys key_data)
Initializes a new instance of the key_event_args class.
Definition key_event_args.h:34
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:81
bool control() const noexcept
Gets a value indicating whether the CTRL key was pressed.
Definition key_event_args.h:55
bool handled() const noexcept
Gets a value indicating whether the event was handled.
Definition key_event_args.h:60
void handled(bool handled)
Sets a value indicating whether the event was handled.
Definition key_event_args.h:64
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:77
bool shift() const noexcept
Gets a value indicating whether the SHIFT key was pressed.
Definition key_event_args.h:85
bool command() const noexcept
Gets a value indicating whether the CMD key was pressed.
Definition key_event_args.h:51
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:91
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:68
bool alt() const noexcept
Gets a value indicating whether the ALT key was pressed.
Definition key_event_args.h:47
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:96
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:73
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
keys
Specifies key codes and modifiers.
Definition keys.h:77
@ 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