xtd.forms - Reference Guide  0.1.0
Modern c++17 library containing classes for creating Windows-based applications that take full advantage of the rich user interface features available in the Microsoft Windows, Apple macOS and Linux like Ubuntu operating system.
key_event_args.h
1 #pragma once
2 
3 #include <xtd/event_args.h>
4 #include "keys.h"
5 
7 namespace xtd {
9  namespace forms {
10  class key_event_args : public event_args {
11  public:
12  key_event_args() = default;
13 
14  key_event_args(keys key_data) : key_data_(key_data) {}
15  //key_event_args(keys key_data, int key_value) : key_data_(key_data), key_value_(key_value) {}
16 
19  key_event_args& operator=(const key_event_args& key_event_args) = default;
21 
22  bool alt() const {return (this->key_data_ & keys::alt) == keys::alt;}
23 
24  bool command() const {return (this->key_data_ & keys::command) == keys::command;}
25 
26  bool control() const {return (this->key_data_ & keys::control) == keys::control;}
27 
28  bool handled() const {return this->handled_;}
29  void handled(bool handled) {this->handled_ = handled;}
30 
31  keys key_code() const {return this->key_data_ & keys::key_code;}
32 
33  keys key_data() const {return this->key_data_;}
34 
35  int key_value() const {return static_cast<int>(this->key_data_) & 0xFFFF;}
36  //int key_value() const {return this->key_value_;}
37 
38  keys modifiers() const {return this->key_data_ & keys::modifiers;}
39 
40  bool shift() const {return (this->key_data_ & keys::shift) == keys::shift;}
41 
42  bool suppress_key_press() const {return this->suppress_key_press_;}
43  void suppress_key_press(bool suppress_key_press) {
44  this->suppress_key_press_ = suppress_key_press;
45  if (suppress_key_press) this->handled(true);
46  }
47 
48  private:
49  keys key_data_;
50  bool handled_ = false;
51  bool suppress_key_press_ = false;
52  };
53  }
54 }
The CTRL modifier key.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
The bitmask to extract a key code from a key value.
The CMD modifier key.
The bitmask to extract modifiers from a key value.
The ALT modifier key.
Defines the base class for controls, which are components with visual representation.
Definition: control.h:59
Contains keys enum.
The SHIFt modifier key.
keys
Specifies key codes and modifiers.
Definition: keys.h:67
Definition: key_event_args.h:10