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

◆ click

event<control, event_handler> xtd::forms::control::click

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

Remarks
The xtd::forms::control::click event passes an xtd::event_args to its event handler, so it only indicates that a click has occurred. If you need more specific mouse information (button, number of clicks, wheel rotation, or location), use the xtd::forms::control::mouse_click event. However, the xtd::forms::control::mouse_click event will not be raised if the click is caused by action other than that of the mouse, such as pressing the ENTER key.
A double-click is determined by the mouse settings of the user's operating system. The user can set the time between clicks of a mouse button that should be considered a double-click rather than two clicks. The xtd::forms::control::click event is raised every time a control is double-clicked. For example, if you have event handlers for the xtd::forms::control::click and xtd::forms::control::double_click events of a xtd::forms::form, the xtd::forms::control::click and xtd::forms::control::double_click events are raised when the form is double-clicked and both methods are called. If a control is double-clicked and that control does not support the xtd::forms::control::double_click event, the xtd::forms::control::click event might be raised twice.
You must set the standard_click value of xtd::forms::control_styles to true for this event to be raised.
Note
The following events are not raised for the xtd::forms::tab_control class unless there is at least one xtd::forms::tab_page in the xtd::forms::tab_control. xtd::forms::tab_control::tab_pages collection: xtd::forms::control::click, xtd::forms::control::double_click, xtd::forms::control::mouse_down, xtd::forms::control::mouse_up, xtd::forms::control::mouse_hover, xtd::forms::control::mouse_enter, xtd::forms::control::mouse_leave and xtd::forms::control::mouse_move. If there is at least one xtd::forms::tab_page in the collection, and the user interacts with the tab control's header (where the xtd::forms::tab_page names appear), the xtd::forms::tab_control raises the appropriate event. However, if the user interaction is within the client area of the tab page, the xtd::forms::tab_page raises the appropriate event.
Notes to Inheritors
Inheriting from a standard Windows Forms control and changing the standard_click or standard_double_click values of xtd::forms::control_styles to true can cause unexpected behavior or have no effect at all if the control does not support the click or xtd::forms::control::double_click events.
Remarks
The following table lists Windows Forms controls and which event (xtd::forms::control::click or xtd::forms::control::double_click) is raised in response to the mouse action specified.
Control Left Mouse Click Left Mouse Double Click Right Mouse Click Right Mouse Click Middle Mouse Click Middle Mouse Double Click XButton1 Mouse Click XButton1 Mouse Double-Click XButton2 Mouse Click XButton2 Mouse Double-Click
xtd::forms::month_calendar, xtd::forms::date_time_picker, xtd::forms::h_scroll_bar, xtd::forms::v_scroll_bar none none none none none none none none none none
xtd::forms::button, xtd::forms::check_box, xtd::forms::color_picker, xtd::forms::command_link_button, xtd::forms::font_picker, xtd::forms::rich_text_box, xtd::forms::radio_button, xtd::forms::switch_button, xtd::forms::toggle_button click click, click none none none none none none none none
xtd::forms::list_box, xtd::forms::checked_list_box, xtd::forms::choice, xtd::forms::combo_box click click, double_click none none none none none none none none
xtd::forms::text_box, xtd::forms::domain_up_down, xtd::forms::numeric_up_down click click, double_click none none none none none none none none
* xtd::forms::tree_view, * xtd::forms::list_view click click, double_click click click, double_click none none none none none none
xtd::forms::progress_bar, xtd::forms::track_bar click click, click click click, click click click, click click click, click click click, click
xtd::forms::form, xtd::forms::collapsible_panel, xtd::forms::data_grid, xtd::forms::dot_matrix_display, xtd::forms::label, xtd::forms::lcd_label, xtd::forms::link_label, xtd::forms::nine_segment_display, xtd::forms::seven_segment_display, xtd::forms::sixteen_segment_display, xtd::forms::panel, xtd::forms::group_box, xtd::forms::picture_box, xtd::forms::splitter, xtd::forms::status_bar, xtd::forms::tool_bar, xtd::forms::tab_page, ** xtd::forms::tab_control click click, double_click click click, double_click click click, double_click click click, double_click click click, double_click

* The mouse pointer must be over a child object (xtd::forms::tree_node or xtd::forms::list_view_item).
** The xtd::forms::tab_control must have at least one xtd::forms::tab_page in its xtd::forms::tab_pages collection.
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
clock.cpp, demo.cpp, dialog.cpp, emplace.cpp, form2.cpp, form_and_main.cpp, and form_background_image.cpp.