xtd 1.0.0
Loading...
Searching...
No Matches
key_event_args.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "keys.hpp"
6#include <xtd/event_args>
7
9namespace xtd {
11 namespace forms {
26 public:
28
31 key_event_args() = default;
36
37
39
43 [[nodiscard]] auto alt() const noexcept -> bool {return (key_data_ & xtd::forms::keys::alt) == keys::alt;}
44
47 [[nodiscard]] auto command() const noexcept -> bool {return (key_data_ & xtd::forms::keys::command) == keys::command;}
48
51 [[nodiscard]] auto control() const noexcept -> bool {return (key_data_ & xtd::forms::keys::control) == keys::control;}
52
56 [[nodiscard]] auto handled() const noexcept -> bool {return handled_;}
60 auto handled(bool value) -> key_event_args& {
61 handled_ = value;
62 return *this;
63 }
64
67 [[nodiscard]] auto key_code() const noexcept -> xtd::forms::keys {return key_data_ & xtd::forms::keys::key_code;}
68
72 [[nodiscard]] auto key_data() const noexcept -> xtd::forms::keys {return key_data_;}
73
76 [[nodiscard]] auto key_value() const noexcept -> xtd::int32 {return static_cast<xtd::int32>(key_data_) & 0xFFFF;}
77
80 [[nodiscard]] auto modifiers() const noexcept -> xtd::forms::keys {return key_data_ & xtd::forms::keys::modifiers;}
81
84 [[nodiscard]] auto shift() const noexcept -> bool {return (key_data_ & xtd::forms::keys::shift) == keys::shift;}
85
90 [[nodiscard]] auto suppress_key_press() const noexcept -> bool {return suppress_key_press_;}
95 auto suppress_key_press(bool value) -> key_event_args& {
96 suppress_key_press_ = value;
97 if (value) handled(true);
98 return *this;
99 }
100
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.hpp:18
auto key_value() const noexcept -> xtd::int32
Gets the keyboard value for a xtd::forms::control::key_down or xtd::forms::control::key_up event.
Definition key_event_args.hpp:76
key_event_args(xtd::forms::keys key_data)
Initializes a new instance of the key_event_args class.
Definition key_event_args.hpp:34
auto key_code() const noexcept -> xtd::forms::keys
Gets the keyboard code for a xtd::forms::control::key_down or xtd::forms::control::key_up event.
Definition key_event_args.hpp:67
auto suppress_key_press(bool value) -> key_event_args &
Sets a value indicating whether the key event should be passed on to the underlying control.
Definition key_event_args.hpp:95
auto handled() const noexcept -> bool
Gets a value indicating whether the event was handled.
Definition key_event_args.hpp:56
auto command() const noexcept -> bool
Gets a value indicating whether the CMD key was pressed.
Definition key_event_args.hpp:47
auto key_data() const noexcept -> xtd::forms::keys
Gets the key data for a xtd::forms::control::key_down or xtd::forms::control::key_up event.
Definition key_event_args.hpp:72
auto control() const noexcept -> bool
Gets a value indicating whether the CTRL key was pressed.
Definition key_event_args.hpp:51
auto alt() const noexcept -> bool
Gets a value indicating whether the ALT key was pressed.
Definition key_event_args.hpp:43
auto suppress_key_press() const noexcept -> bool
Gets a value indicating whether the key event should be passed on to the underlying control.
Definition key_event_args.hpp:90
auto shift() const noexcept -> bool
Gets a value indicating whether the SHIFT key was pressed.
Definition key_event_args.hpp:84
key_event_args()=default
Initializes a new instance of the key_event_args class.
auto handled(bool value) -> key_event_args &
Sets a value indicating whether the event was handled.
Definition key_event_args.hpp:60
auto modifiers() const noexcept -> xtd::forms::keys
Gets the modifier flags for a xtd::forms::control::key_down or xtd::forms::control::key_up event....
Definition key_event_args.hpp:80
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
keys
Specifies key codes and modifiers.
Definition keys.hpp:77
@ command
The CMD modifier key.
Definition keys.hpp:469
@ shift
The SHIFt modifier key.
Definition keys.hpp:463
@ none
No key pressed.
Definition keys.hpp:79
@ alt
The ALT modifier key.
Definition keys.hpp:471
@ key_code
The bitmask to extract a key code from a key value.
Definition keys.hpp:482
@ modifiers
The bitmask to extract modifiers from a key value.
Definition keys.hpp:484
@ control
The CTRL modifier key.
Definition keys.hpp:466
Contains xtd::forms::keys enum class.
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition texts.hpp:219
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8