xtd 0.2.0
Loading...
Searching...
No Matches
key_events.cpp

demonstrates some events received by form.

Windows

macOS

Gnome

#define TRACE
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/trace_form>
#include <xtd/ctrace>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Key events example");
control1.dock(dock_style::fill);
control1.parent(*this);
control1.key_down += [&](object & sender, key_event_args & e) {
ctrace << string::format("key_down={{key_code={}, key_data=[{}], value=0x{:X4}, modifiers=[{}]}}", e.key_code(), e.key_data(), e.key_value(), e.modifiers()) << environment::new_line;
};
control1.key_press += [&](object & sender, key_press_event_args & e) {
ctrace << string::format("key_press={{key_char={}}}", e.key_char() == 0 ? "[none]" : string::format("'{}'", e.key_char())) << environment::new_line;
};
control1.key_up += [&](object & sender, key_event_args & e) {
ctrace << string::format("key_up={{key_code={}, key_data=[{}], value=0x{:X4}, modifiers=[{}]}}", e.key_code(), e.key_data(), e.key_value(), e.modifiers()) << environment::new_line;
if (e.modifiers() == keys::none) ctrace << environment::new_line;
};
}
private:
control control1;
};
auto main() -> int {
application::run(form1 {});
}
Defines the base class for controls, which are components with visual representation.
Definition control.h:81
Represents a window or dialog box that makes up an application's user interface.
Definition form.h:54
Provides data for the xtd::forms::control::key_down or xtd::forms::control::key_up event.
Definition key_event_args.h:25
Provides data for the xtd::forms::control::key_press event.
Definition key_press_event_args.h:26
Represents a form that displays trace form. This class cannot be inherited.
Definition trace_form.h:36
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