demonstrates how to create custom event with form.
#include <xtd/forms/application>
#include <xtd/forms/button>
#include <xtd/forms/form>
#include <xtd/forms/message_box>
namespace custom_event_example {
public:
explicit custom_event_args(const std::any& tag) noexcept : tag_ {tag} {}
std::any tag() const noexcept {return tag_;}
private:
std::any tag_;
};
class form1 :
public form {
public:
form1() {
text(
"Form custom event example");
static auto counter = 0;
custom_event.invoke(*this, custom_event_args {++counter});
};
custom_event += [&](
object& sender,
const custom_event_args&
e) {
message_box::show(*
this, string::format(
"Receive custom_event event ({})", any_cast<int>(
e.tag())),
"Custom event");
};
}
private:
};
}
auto main() -> int {
}
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.hpp:18
Represents an event.
Definition event.hpp:21
xtd::delegate< void(xtd::object &sender, event_args_t e)> generic_event_handler
Represents the method that will handle an event when the event provides data.
Definition generic_event_handler.hpp:30
@ e
The E key.
Definition console_key.hpp:96
Contains classes that represent ASCII and Unicode character encodings; abstract base classes for conv...
Definition basic_string_builder.hpp:16
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8