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 std;
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 << ustring::format("key_down={{key_code={}, key_data=[{}], value=0x{:X4}, modifiers=[{}]}}", e.key_code(), e.key_data(), e.key_value(), e.modifiers()) << endl;
};
control1.key_press += [&](object & sender, key_press_event_args & e) {
ctrace << ustring::format("key_press={{key_char={}}}", e.key_char() == 0 ? "[none]" : ustring::format("'{}'", e.key_char())) << endl;
};
control1.key_up += [&](object & sender, key_event_args & e) {
ctrace << ustring::format("key_up={{key_code={}, key_data=[{}], value=0x{:X4}, modifiers=[{}]}}", e.key_code(), e.key_data(), e.key_value(), e.modifiers()) << endl;
if (e.modifiers() == keys::none) ctrace << endl;
};
}
private:
control control1;
};
auto main()->int {
application::run(form1 {});
}
Defines the base class for controls, which are components with visual representation.
Definition control.h:79
Represents a window or dialog box that makes up an application's user interface.
Definition form.h:52
Provides data for the xtd::forms::control::key_down or xtd::forms::control::key_up event.
Definition key_event_args.h:23
Provides data for the xtd::forms::control::key_press event.
Definition key_press_event_args.h:24
Represents a form that displays trace form. This class cannot be inherited.
Definition trace_form.h:34
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