xtd 0.2.0
Loading...
Searching...
No Matches
xtd::forms::key_event_args Class Reference
Inheritance diagram for xtd::forms::key_event_args:
xtd::event_args xtd::object

Definition

Provides data for the xtd::forms::control::key_down or xtd::forms::control::key_up event.

Header
#include <xtd/forms/key_event_args>
Namespace
xtd::forms
Library
xtd.forms
Remarks
A key_event_args, which specifies the key the user pressed and whether any modifier keys (CMD, CTRL, ALT, and SHIFT) were pressed at the same time, is passed with each xtd::forms::control::key_down or xtd::forms::control::key_up event.
The xtd::forms::control::key_down event occurs when the user presses any key. The xtd::forms::control::key_up event occurs when the user releases the key. Duplicate xtd::forms::control::key_down events occur each time the key repeats, if the key is held down, but only one xtd::forms::control::key_up event is generated when the user releases the key.
The xtd::forms::control::key_press event also occurs when a key is pressed. A xtd::forms::key_press_event_args is passed with each xtd::forms::control::key_press event, and specifies the character that was composed as a result of each key press.
Examples
form_show.cpp, key_events.cpp, and test_forms.cpp.

Public Constructors

 key_event_args ()=default
 Initializes a new instance of the key_event_args class.
 
 key_event_args (xtd::forms::keys key_data)
 Initializes a new instance of the key_event_args class.
 

Public Properties

bool alt () const noexcept
 Gets a value indicating whether the ALT key was pressed.
 
bool command () const noexcept
 Gets a value indicating whether the CMD key was pressed.
 
bool control () const noexcept
 Gets a value indicating whether the CTRL key was pressed.
 
bool handled () const noexcept
 Gets a value indicating whether the event was handled.
 
void handled (bool handled)
 Sets a value indicating whether the event was handled.
 
keys key_code () const noexcept
 Gets the keyboard code for a xtd::forms::control::key_down or xtd::forms::control::key_up event.
 
keys key_data () const noexcept
 Gets the key data for a xtd::forms::control::key_down or xtd::forms::control::key_up event.
 
int32 key_value () const noexcept
 Gets the keyboard value for a xtd::forms::control::key_down or xtd::forms::control::key_up event.
 
keys modifiers () const noexcept
 Gets the modifier flags for a xtd::forms::control::key_down or xtd::forms::control::key_up event. The flags indicate which combination of CMD, CTRL, SHIFT, and ALT keys was pressed.
 
bool shift () const noexcept
 Gets a value indicating whether the SHIFT key was pressed.
 
bool suppress_key_press () const noexcept
 Gets a value indicating whether the key event should be passed on to the underlying control.
 
void suppress_key_press (bool suppress_key_press)
 Sets a value indicating whether the key event should be passed on to the underlying control.
 

Additional Inherited Members

- Static Public Attributes inherited from xtd::event_args
static const event_args empty
 Provides a value to use with events that do not have event data.
 
- Public Member Functions inherited from xtd::event_args
 event_args ()=default
 Initializes a new instance of the event_args class.
 
- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object.
 
bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const noexcept
 Creates a shallow copy of the current object.
 
virtual xtd::ustring to_string () const noexcept
 Returns a sxd::ustring that represents the current object.
 
- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 

Constructor & Destructor Documentation

◆ key_event_args() [1/2]

xtd::forms::key_event_args::key_event_args ( )
default

Initializes a new instance of the key_event_args class.

◆ key_event_args() [2/2]

xtd::forms::key_event_args::key_event_args ( xtd::forms::keys  key_data)
inlineexplicit

Initializes a new instance of the key_event_args class.

Parameters
key_dataA xtd::forms::keys representing the key that was pressed, combined with any modifier flags that indicate which CMD, CTRL, SHIFT, and ALT keys were pressed at the same time. Possible values are obtained by applying the bitwise OR (|) operator to constants from the Keys enumeration.

Member Function Documentation

◆ alt()

bool xtd::forms::key_event_args::alt ( ) const
inlinenoexcept

Gets a value indicating whether the ALT key was pressed.

Returns
true if the ALT key was pressed; otherwise, false.

◆ command()

bool xtd::forms::key_event_args::command ( ) const
inlinenoexcept

Gets a value indicating whether the CMD key was pressed.

Returns
true if the CMD key was pressed; otherwise, false.

◆ control()

bool xtd::forms::key_event_args::control ( ) const
inlinenoexcept

Gets a value indicating whether the CTRL key was pressed.

Returns
true if the CTRL key was pressed; otherwise, false.

◆ handled() [1/2]

bool xtd::forms::key_event_args::handled ( ) const
inlinenoexcept

Gets a value indicating whether the event was handled.

Returns
true to bypass the control's default handling; otherwise, false to also pass the event along to the default control handler.
Remarks
handled is implemented differently by different controls within xtd.forms. For controls like text_box which subclass native Win32 controls, it is interpreted to mean that the key message should not be passed to the underlying native control. If you set handled to true on a text_box, that control will not pass the key press events to the underlying Win32 text box control, but it will still display the characters that the user typed.

◆ handled() [2/2]

void xtd::forms::key_event_args::handled ( bool  handled)
inline

Sets a value indicating whether the event was handled.

Parameters
handledtrue to bypass the control's default handling; otherwise, false to also pass the event along to the default control handler.
Remarks
handled is implemented differently by different controls within xtd.forms. For controls like text_box which subclass native Win32 controls, it is interpreted to mean that the key message should not be passed to the underlying native control. If you set handled to true on a text_box, that control will not pass the key press events to the underlying Win32 text box control, but it will still display the characters that the user typed.

◆ key_code()

keys xtd::forms::key_event_args::key_code ( ) const
inlinenoexcept

Gets the keyboard code for a xtd::forms::control::key_down or xtd::forms::control::key_up event.

Returns
A xtd::forms::keys value that is the key code for the event.

◆ key_data()

keys xtd::forms::key_event_args::key_data ( ) const
inlinenoexcept

Gets the key data for a xtd::forms::control::key_down or xtd::forms::control::key_up event.

Returns
A xtd::forms::keys representing the key code for the key that was pressed, combined with modifier flags that indicate which combination of CMD, CTRL, SHIFT, and ALT keys was pressed at the same time.
Remarks
You can use constants from Keys to extract information from the key_data property. Use the bitwise AND operator to compare data returned by key_data with constants in Keys to obtain information about which keys the user pressed. To determine whether a specific modifier key was pressed, use the command, control, shift, and alt properties.

◆ key_value()

int32 xtd::forms::key_event_args::key_value ( ) const
inlinenoexcept

Gets the keyboard value for a xtd::forms::control::key_down or xtd::forms::control::key_up event.

Returns
The integer representation of the key_code property.

◆ modifiers()

keys xtd::forms::key_event_args::modifiers ( ) const
inlinenoexcept

Gets the modifier flags for a xtd::forms::control::key_down or xtd::forms::control::key_up event. The flags indicate which combination of CMD, CTRL, SHIFT, and ALT keys was pressed.

Returns
A xtd::forms::keys value representing one or more modifier flags.

◆ shift()

bool xtd::forms::key_event_args::shift ( ) const
inlinenoexcept

Gets a value indicating whether the SHIFT key was pressed.

Returns
true if the SHIFT key was pressed; otherwise, false.

◆ suppress_key_press() [1/2]

bool xtd::forms::key_event_args::suppress_key_press ( ) const
inlinenoexcept

Gets a value indicating whether the key event should be passed on to the underlying control.

Returns
true if the key event should not be sent to the control; otherwise, false.
Remarks
You can assign true to this property in an event handler such as xtd::forms::control::key_down in order to prevent user input.
Setting suppress_key_press to true also sets handled to true.

◆ suppress_key_press() [2/2]

void xtd::forms::key_event_args::suppress_key_press ( bool  suppress_key_press)
inline

Sets a value indicating whether the key event should be passed on to the underlying control.

Parameters
suppress_key_presstrue if the key event should not be sent to the control; otherwise, false.
Remarks
You can assign true to this property in an event handler such as xtd::forms::control::key_down in order to prevent user input.
Setting suppress_key_press to true also sets handled to true.

The documentation for this class was generated from the following file: