xtd 0.2.0
Loading...
Searching...
No Matches

◆ mouse_click

event<control, mouse_event_handler> xtd::forms::control::mouse_click

Occurs when the xtd::forms::control is clicked by the mouse.

Remarks
Depressing a mouse button when the cursor is over a control typically raises the following series of events from the control:
  1. xtd::forms::control::mouse_down event
  2. xtd::forms::control::click event
  3. xtd::forms::control::mouse_click event
  4. xtd::forms::control::mouse_up event
For this to occur, the various events cannot be disabled in the control's class.
Two single clicks that occur close enough in time, as determined by the mouse settings of the user's operating system, will generate a xtd::forms::control::mouse_double_click event instead of the second xtd::forms::control::mouse_click event.
important
click events are logically higher-level events of a control. They are often raised by other actions, such as pressing the ENTER key when the control has focus.
Examples
The following code example demonstrates the use of control mouse events.
#define TRACE
#include <xtd/forms/application>
#include <xtd/forms/form>
#include <xtd/forms/trace_form>
#include <xtd/diagnostics/trace>
using namespace xtd;
using namespace xtd::forms;
class form1 : public form {
public:
form1() {
text("Mouse events example");
click += [&] {
};
double_click += [&] {
};
mouse_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_double_click += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_double_click={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_down += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_down={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_enter += [&] {
};
mouse_horizontal_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_horizontal_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_leave += [&] {
};
mouse_move += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_move={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_up += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_up={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
mouse_wheel += [&](object & sender, const mouse_event_args & e) {
xtd::diagnostics::trace::write_line("mouse_wheel={{button={}, clicks={}, delta={}, location=[{}], modifier_keys=[{}]}}", e.button(), e.clicks(), e.delta(), e.location(), modifier_keys());
};
}
};
auto main() -> int {
application::run(form1 {});
}
static void write_line()
Writes a line terminator to the trace listeners in the listeners collection.
Definition trace.h:358
static void run()
Begins running a standard application message loop on the current thread, without a form.
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::mouse_up, xtd::forms::control::mouse_down,...
Definition mouse_event_args.h:34
Represents a form that displays trace form. This class cannot be inherited.
Definition trace_form.h:36
@ e
The E key.
@ text
The xtd::forms::status_bar_panel displays text in the standard font.
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
Remarks
For more information about handling events, see Handling and Raising Events.
Examples
form_click.cpp.