The Battle for Wesnoth  1.17.12+dev
dispatcher.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2022
3  by Mark de Wever <koraq@xs4all.nl>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #define GETTEXT_DOMAIN "wesnoth-lib"
17 
19 
21 #include "gui/core/log.hpp"
22 
23 namespace gui2
24 {
25 namespace event
26 {
27 /***** dispatcher class. *****/
28 
30  : mouse_behavior_(mouse_behavior::all)
31  , want_keyboard_input_(true)
32  , signal_queue_()
33  , signal_mouse_queue_()
34  , signal_keyboard_queue_()
35  , signal_touch_motion_queue_()
36  , signal_touch_gesture_queue_()
37  , signal_notification_queue_()
38  , signal_message_queue_()
39  , connected_(false)
40  , hotkeys_()
41 {
42 }
43 
45 {
46  if(connected_) {
47  disconnect();
48  }
49 }
50 
52 {
53  assert(!connected_);
54  connected_ = true;
55  connect_dispatcher(this);
56 }
57 
59 {
60  assert(connected_);
61  connected_ = false;
63 }
64 
65 bool dispatcher::has_event(const ui_event event, const event_queue_type event_type)
66 {
67 #if 0
68  const bool res = dispatcher_implementation::has_handler(*this, event_type, event);
69  PLAIN_LOG << "Event '" << event << " '" << (res ? "found" : "not found") << "in queue";
70  return res;
71 #else
72  return dispatcher_implementation::has_handler(*this, event_type, event);
73 #endif
74 }
75 
76 bool dispatcher::fire(const ui_event event, widget& target)
77 {
79  switch(event) {
83 
87 
91 
92  default:
93  return fire_event<event_category::general>(event, this, &target);
94  }
95 }
96 
97 bool dispatcher::fire(const ui_event event, widget& target, const point& coordinate)
98 {
99  assert(is_in_category(event, event_category::mouse));
100  return fire_event<event_category::mouse>(event, this, &target, coordinate);
101 }
102 
103 bool dispatcher::fire(const ui_event event,
104  widget& target,
105  const SDL_Keycode key,
106  const SDL_Keymod modifier,
107  const std::string& unicode)
108 {
110  return fire_event<event_category::keyboard>(event, this, &target, key, modifier, unicode);
111 }
112 
113 bool dispatcher::fire(const ui_event event, widget& target, const point& pos, const point& distance)
114 {
116  return fire_event<event_category::touch_motion>(event, this, &target, pos, distance);
117 }
118 
119 bool dispatcher::fire(const ui_event event, widget& target, const point& center, float dTheta, float dDist, uint8_t numFingers)
120 {
122  return fire_event<event_category::touch_gesture>(event, this, &target, center, dTheta, dDist, numFingers);
123 }
124 
125 bool dispatcher::fire(const ui_event event, widget& target, const SDL_Event& sdlevent)
126 {
128  return fire_event<event_category::raw_event>(event, this, &target, sdlevent);
129 }
130 
131 bool dispatcher::fire(const ui_event event, widget& target, const std::string& text, int32_t start, int32_t len)
132 {
134  return fire_event<event_category::text_input>(event, this, &target, text, start, len);
135 }
136 
137 bool dispatcher::fire(const ui_event event, widget& target, void*)
138 {
140  return fire_event<event_category::notification>(event, this, &target, nullptr);
141 }
142 
143 bool dispatcher::fire(const ui_event event, widget& target, const message& msg)
144 {
145  assert(is_in_category(event, event_category::message));
146  return fire_event<event_category::message>(event, this, &target, msg);
147 }
148 
150 {
151  hotkeys_[id] = function;
152 }
153 
155 {
157 
158  if(itor == hotkeys_.end()) {
159  return false;
160  }
161 
162  itor->second(dynamic_cast<widget&>(*this), id);
163 
164  /* NOTE: hotkey events used to return bool to indicate was-handled status. However,
165  * every single usecase was returning true and cluttering up the code. I changed
166  * the signature to return void, but if there's ever a need to restore the bool
167  * retval on the hotkey functions, this is where it should be handled.
168  *
169  * -- vultraz, 2017-11-27
170  */
171  return true;
172 }
173 
175 {
177 }
178 
180 {
182 }
183 
185 {
187 }
188 
190 {
191  dispatcher.connect_signal<LEFT_BUTTON_UP>(signal);
192 }
193 
195 {
197 }
198 
199 
201 {
203 }
204 
206 {
208 }
209 
211 {
212  // TODO: evaluate whether draw events need go in this queue position.
214 }
215 
216 } // namespace event
217 
218 } // namespace gui2
219 
220 /**
221  * @page event_dispatching Event dispatching.
222  *
223  * @section introduction-event_dispatching Introduction
224  *
225  * This page describes how the new event handling system works, since the
226  * system is still work in progress it might be out of date with the actual
227  * code. It also contains some ideas that might change later on. Some parts are
228  * explained in the interface and will be integrated in this document later.
229  *
230  * Since the event handling code hasn't been cast in stone yet some scenarios
231  * for solving the problem are discussed first and then the solution that is
232  * chosen in more detail.
233  *
234  * After SDL has generated and event it needs to be turned into an event which
235  * the widgets can use.
236  *
237  * @section handling_solution The implementation solutions.
238  *
239  * For the event handling we use a few use case scenarios and show the possible
240  * solutions.
241  *
242  * @subsection sample The sample window
243  *
244  * In our samples we use this sample window with the following components:
245  * - a window W
246  * - a container C
247  * - a button B
248  *
249  * These are arranged accordingly:
250  * @code
251  *
252  * ---------------------
253  * |W |
254  * | |
255  * | ----------------- |
256  * | |C |^| |
257  * | | |-| |
258  * | | ---------- |#| |
259  * | | |B | | | |
260  * | | ---------- | | |
261  * | | |-| |
262  * | | |v| |
263  * | ----------------- |
264  * | |
265  * ---------------------
266  *
267  * @endcode
268  *
269  * @subsection scenarios Possible scenarios
270  *
271  * The scenarios are:
272  * - An event that is wanted by none.
273  * - A mouse down event that should focus C and set the pressed state in B.
274  * - A mouse wheel event, which first should be offered to B and if not handled
275  * by B should be handled by C.
276  *
277  * @subsection all_queues Pass the event through all queues
278  *
279  * In this solution the event will be passed through all possible queues and
280  * tries sees where the event sticks. This following sections describe how the
281  * events are tried for this usage scenario.
282  *
283  * @subsubsection unhandled-all_queues Unhandled event
284  *
285  * - W pre child
286  * - C pre child
287  * - B pre child
288  * - W child
289  * - C child
290  * - B child
291  * - W post child
292  * - C post child
293  * - B post child
294  *
295  * @subsubsection mouse_down-all_queues Mouse down
296  *
297  * - W pre child
298  * - C pre child -> set focus -> !handled
299  * - B pre child -> set pressed state -> handled
300  *
301  * @subsubsection mouse_wheel-all_queues Mouse wheel
302  *
303  * - W pre child
304  * - C pre child
305  * - B pre child -> We can't scroll so ignore
306  * - W child
307  * - C child
308  * - B child
309  * - W post child
310  * - C post child -> Scroll -> handled
311  *
312  * @subsection chain Pass the events in a chain like fashion
313  *
314  * In this solution the events are send to the pre- and post queue of all but
315  * the last possible widget and to the child of the last widget. The pre queue
316  * will be send from top to bottom, the post queue from bottom to top.
317  *
318  * @subsubsection unhandled-chain Unhandled event
319  *
320  * - W pre child
321  * - C pre child
322  * - B child
323  * - C post child
324  * - W post child
325  *
326  * @subsubsection mouse_down-chain Mouse down
327  *
328  * - W pre child
329  * - C pre child -> set focus -> !handled
330  * - B child -> set pressed state -> handled
331  *
332  * @subsubsection mouse_wheel-chain Mouse wheel
333  *
334  * - W pre child
335  * - C pre child
336  * - B child -> We can't scroll so ignore
337  * - C post child -> Scroll -> handled
338  *
339  * @subsection evaluation Evaluation
340  *
341  * When using the first solution it's possible to drop the child queue since
342  * everything falls in pre or post. But there is a scenario that's a bit ugly
343  * to solve with the first solution:
344  *
345  * Assume there is a listbox with toggle panels and on the panel there are a
346  * few buttons, the wanted behavior is:
347  * - if clicked on the panel it should toggle, which may or may not be allowed.
348  * - if clicked on a button in the panel, we want to make sure the panel is
349  * selected, which again may or may not be allowed.
350  *
351  * With solution 2 it's rather easy:
352  *
353  * Click on panel:
354  * - W pre child
355  * - C child -> Test whether we can toggle -> handled, halt = !toggled
356  *
357  * Click on button in panel:
358  * - W pre child
359  * - C pre child -> Test whether we can select -> handled = halt = !selected
360  * - B child -> do button stuff -> handled
361  *
362  * Since for the different clicks, different queues are triggered it's easy to
363  * add a different handler there.
364  *
365  * With solution 1:
366  *
367  * Click on panel:
368  * - W pre child
369  * - C pre child -> handler 1 -> if last in queue -> solution 2 C child
370  *
371  * Click on button in panel:
372  * - W pre child
373  * - C pre child -> handler 2 -> if !last in queue -> solution 2 C pre child
374  * - B pre child -> do button stuff -> handled
375  *
376  * Not that different from solution 2, the two handlers are installed in the C
377  * pre event. But we need to manually check whether we're really the last,
378  * which means the code to check whether there are more handlers at a lower
379  * level is needed for both solutions. In solution 1 this test needs to be done
380  * twice versus once in solution 2. Also the fact that the queues for the
381  * events are processed in reverse order on the way back sounds more
382  * initiative.
383  *
384  * @section processing_raw_events Processing the raw events.
385  *
386  * This section describes how the events generated by SDL are send as our own
387  * events to the various widgets. The first step in sending an event is to
388  * decode it and send it to a registered dispatcher.
389  *
390  * - gui2::event::sdl_event_handler handles the SDL events.
391  * - gui2::event::dispatcher has the registered dispatchers.
392  *
393  * In general a dispatcher is a window which then needs to send this event to
394  * the widgets. The dispatcher is just a simple part which fires events and
395  * finds a handler for the event. This is not to the liking of most widgets,
396  * they don't want to handle raw events but get a polished and clean event. No
397  * button up and down and then try to figure out whether it needs to act as if
398  * it was clicked upon, no simply op and down to change the appearance and a
399  * click event to do the clicking actions. And don't even try to convince a
400  * widget to determine whether this up event was a single or double click.
401  * Widgets like to sleep with nice dreams and not having nightmares where SDL
402  * events haunt them.
403  *
404  * In order to remedy that problem there's the gui2::event::distributor
405  * class, it's the class to do the dirty job of converting the raw event into
406  * these nice polished events. The distributor is in general linked to a window,
407  * but a widget can install it's own distributor if it needs to know more of the
408  * raw events as still left in the polished events. At the time of this writing
409  * no widget needs this feature, but the toggle panel might need it.
410  *
411  * After the distributor has polished the event and send it on its way to the
412  * widget the dispatcher needs to make sure the event is properly dispatched to
413  * the widget in question and also notify its parents by means of the previously
414  * described event chain.
415  *
416  * @subsection sdl_event Get the SDL events
417  *
418  * The first step in event handling is getting the events in the first place.
419  * Events are generated by SDL and placed in a queue. The Wesnoth code processes
420  * this queue and thus handles the events. The part which does the first
421  * handling isn't described here since it's (secretly) intended to be replaced
422  * by the @ref gui2::event::sdl_event_handler class. Instead we directly jump to this
423  * class and explain what it does.
424  *
425  * The main handling function is @ref gui2::event::sdl_event_handler::handle_event which
426  * as no real surprise handles the events. The function is a simple multiplexer
427  * which lets other subfunctions to the handling of specific events.
428  *
429  * @todo Describe drawing and resizing once the code is stable and working as
430  * wanted in these areas.
431  *
432  * @subsubsection handler_mouse Mouse motion events
433  *
434  * If a dispatcher has captured the mouse it gets the event, no questions asked.
435  * If not it goes through all dispatchers and finds the first one willing to
436  * accept the mouse event.
437  *
438  * This means a mouse event is send to one dispatcher.
439  *
440  * @subsubsection handler_mouse_button_down Mouse button down events
441  *
442  * Turning the mouse wheel on a mouse generates both an down and up event. It
443  * has been decided to handle the wheel event in the button up code so wheel
444  * events are here directly dropped on the floor and forgotten.
445  *
446  * The other buttons are handled as if they're normal mouse events but are
447  * decoded per button so instead of a button_down(id) you get button_down_id.
448  *
449  * @subsubsection handler_mouse_button_up Mouse button up events
450  *
451  * The mouse wheel event is handled as if it's a keyboard event and like the
452  * button_down they are send as wheel_id events.
453  *
454  * The other mouse buttons are handled the same as the down buttons.
455  *
456  * @subsubsection handler_keyboard Keyboard events
457  *
458  * There are three types of keyboard events, the already mentioned mouse wheel
459  * events, the key down and key up event. When a key is pressed for a longer
460  * time several key down events are generated and only one key up, this means
461  * the key up is rather useless. Guess what, the multiplexer already drops that
462  * event so we never get it.
463  *
464  * If the keyboard event is a mouse wheel event it's directly send to the
465  * dispachting queue; either the dispatcher that captured the keyboard or the
466  * last dispatcher in the queue.
467  *
468  * If the event is a real keyboard action it's first tried as hotkey. In order
469  * to do so the target dispatcher is first determined, either the dispatcher
470  * that captured the keyboard or the last dispatcher in the queue. Then it's
471  * tried whether a hotkey and whether the hotkey can be processed. If the
472  * hotkey isn't processed the keyboard event is send to the dispatcher as
473  * normal keyboard event.
474  *
475  * The hotkey processing will have several queues (to be implemented in 1.9):
476  * - global hotkeys that always work eg toggling fullscreen mode.
477  * - main screen hotkeys, these work when one of the dialogs is shown without
478  * other dialogs on top of them. These hotkeys are for example
479  * preferences. The main screens are:
480  * - title screen
481  * - game
482  * - editor
483  * - mp lobby
484  * - map screen hotkeys, these work when a map is shown eg toggle grid. The
485  * screens are:
486  * - game
487  * - editor
488  * - local hotkeys, these are hotkeys that only work in a specific dialog eg
489  * recruit unit only works in the game screen.
490  *
491  * The queues are processed in from bottom to top in the list above, this
492  * allows an item to use a hotkey but have another handler function. Eg
493  * preferences in the editor might open another preferences dialog.
494  *
495  * @todo The hotkeys need to be implemented like above in 1.9.
496  *
497  * @todo This might change in the near future.
498  *
499  * @subsection distributor Event polishing and distribution
500  *
501  * The event distributor has the job to find the widget that should receive the
502  * event and which event(s) to send from a single event. In general an event is
503  * first send to the widget as-is, sending the raw events allows other
504  * distributors to be nested between this distributor and the intended target
505  * widget. Or the intended widget might not really be the intended widget but
506  * another distributor that wants to dispatch the event internally.
507  *
508  * However in the common cases this raw event isn't handled and the distributor
509  * needs to send the polished events. In the following sections the details of
510  * the conversion from raw to polished is described, it intentionally lacks the
511  * part of sending the raw events as well since it adds no value.
512  *
513  * A widget can capture the mouse, which means all mouse events are send to this
514  * widget, regardless where the mouse is. This is normally done in a mouse down
515  * event (for a button) so all events following it are send to that widget.
516  *
517  * @subsection mouse_motion Mouse motion
518  *
519  * This section describes the conversion from a raw mouse motion to the polished
520  * events it can generate:
521  * - @ref gui2::event::MOUSE_ENTER "MOUSE_ENTER"
522  * - @ref gui2::event::MOUSE_LEAVE "MOUSE_LEAVE"
523  * - @ref gui2::event::MOUSE_MOTION "MOUSE_MOTION"
524  *
525  * When the mouse is captured that widget will only receive motion events.
526  *
527  * If not captured the code checks whether the widget underneath the mouse is
528  * the same widget as at the last motion if event. If so that widget gets a
529  * motion event.
530  * If not the widget that before was underneath the mouse pointer (if any) gets
531  * a leave event and the widget newly underneath the mouse pointer (if any) gets
532  * an enter event.
533  *
534  * @subsection mouse_button Mouse buttons
535  *
536  * The mouse button code is a bit more complex and is separated in the various
537  * events to be send.
538  *
539  * @subsubsection mouse_button_down Mouse button down
540  *
541  * Some things start simple, so does the event of pressing down a mouse button.
542  * All it does is send the event to the widget as one of the following events:
543  * - @ref gui2::event::LEFT_BUTTON_DOWN "LEFT_BUTTON_DOWN"
544  * - @ref gui2::event::MIDDLE_BUTTON_DOWN "MIDDLE_BUTTON_DOWN"
545  * - @ref gui2::event::RIGHT_BUTTON_DOWN "RIGHT_BUTTON_DOWN"
546  *
547  * @todo Validate the code it seems a down event with a captured mouse doesn't
548  * really work as wanted. (Rare case but should work properly.) In general the
549  * mouse event handling needs testing to see whether the proper events are send
550  * all the time.
551  *
552  * @subsubsection mouse_button_up Mouse button up
553  *
554  * Simplicity ends here.
555  *
556  * @todo Document further.
557  *
558  * @subsubsection mouse_click Mouse click
559  *
560  * So the button up event has asked for mouse click, now we need to test whether
561  * the click will be a click or a double click. A double click is generated when
562  * the same widget is clicked twice in a short time and causes the following
563  * events:
564  * - @ref gui2::event::LEFT_BUTTON_DOUBLE_CLICK "LEFT_BUTTON_DOUBLE_CLICK"
565  * - @ref gui2::event::MIDDLE_BUTTON_DOUBLE_CLICK "MIDDLE_BUTTON_DOUBLE_CLICK"
566  * - @ref gui2::event::RIGHT_BUTTON_DOUBLE_CLICK "RIGHT_BUTTON_DOUBLE_CLICK"
567  *
568  * Otherwise one of the following single clicks is generated:
569  * - @ref gui2::event::LEFT_BUTTON_CLICK "LEFT_BUTTON_CLICK"
570  * - @ref gui2::event::MIDDLE_BUTTON_CLICK "MIDDLE_BUTTON_CLICK"
571  * - @ref gui2::event::RIGHT_BUTTON_CLICK "RIGHT_BUTTON_CLICK"
572  *
573  * @subsubsection double_click To double click or not to double click
574  *
575  * Wait a second, a widget has a field whether or not it wants a double click
576  * for a certain mouse button and now I see that it's bluntly ignored by the
577  * distributor. Indeed the distributor doesn't care about what the widget wants,
578  * it does what it wants and leaves the sorting out what's wanted to the
579  * dispatcher.
580  *
581  * The problem is that in the chain events are send to one widget that may not
582  * be interested in a double click, but another widget in the chain is. There
583  * are several solutions to this problem:
584  * -# Sending a click followed by a double click.
585  * -# Sending a click with a tag field that it actually is a double click.
586  * -# Send a double click and turn it into a click if the double click is
587  * unwanted.
588  *
589  * The first solution has the disadvantage that a toggle panel likes a click and
590  * double click, the first click selects the second deselects and now the
591  * deselected panel gets a double click. When the panel now checks whether it's
592  * selected it's not and might take the wrong action upon it.
593  *
594  * The second option is possible but would be rather intrusive in the code,
595  * since it would generate another event signature. Adding a signature just for
596  * this special case seemed a bit too much effort vs. gain. Also the widget
597  * needs to check whether a click is a click or a double click and choose a
598  * different code path for it. This in turn would mean a signal handler
599  * secretly might handle two events and lowers the transparency of the code.
600  *
601  * The third option also adds some special case handling but the scope is
602  * limited and only one part knows about the tricks done.
603  *
604  * The last option has been chosen and the dispatcher build the event chain and
605  * while building the chain it looks whether the widget wants the double click
606  * or not. It does this test by looking at the wants double click function and
607  * not test for a handler. The double click test function is made for this
608  * purpose and depending on the handler might again do the wrong thing.
609  * (A certain toggle panel might not want to do something on a double click but
610  * also not being deselected upon a double click. The latter to keep the UI
611  * consistent, a double click on a toggle panel might execute a special function
612  * or not, but always keep the panel selected. (That is if the panel can be
613  * selected.))
614  */
Define the common log macros for the gui toolkit.
Callbacks without extra parameters.
#define PLAIN_LOG
Definition: log.hpp:258
ui_event
The event sent to the dispatcher.
Definition: handler.hpp:115
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
Definition: dispatcher.cpp:179
dispatcher_callback< const SDL_Keycode, const SDL_Keymod, const std::string & > signal_keyboard
Used for events in event_category::keyboard.
Definition: dispatcher.hpp:76
Base class for event handling.
Definition: dispatcher.hpp:151
void register_hotkey(const hotkey::HOTKEY_COMMAND id, const hotkey_function &function)
Registers a hotkey.
Definition: dispatcher.cpp:149
void disconnect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Disconnects a signal handler for a left mouse button click.
Definition: dispatcher.cpp:184
Base class for all widgets.
Definition: widget.hpp:53
static bool has_handler(dispatcher &dispatcher, const dispatcher::event_queue_type queue_type, ui_event event)
A helper to test whether dispatcher has an handler for a certain event.
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:110
bool has_event(const ui_event event, const event_queue_type event_type)
Definition: dispatcher.cpp:65
Generic file dialog.
The message callbacks hold a reference to a message.
Definition: message.hpp:45
std::function< void(widget &dispatcher, hotkey::HOTKEY_COMMAND id)> hotkey_function
Hotkey function handler signature.
Definition: dispatcher.hpp:134
void connect()
Connects the dispatcher to the event handler.
Definition: dispatcher.cpp:51
void connect_signal_mouse_left_release(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button release.
Definition: dispatcher.cpp:189
EXIT_STATUS start(const std::string &filename, bool take_screenshot, const std::string &screenshot_filename)
Main interface for launching the editor from the title screen.
Definition: editor_main.cpp:30
Callbacks with a sender aka notification messages.
dispatcher_callback<> signal
Used for events in event_category::general.
Definition: dispatcher.hpp:58
bool execute_hotkey(const hotkey::HOTKEY_COMMAND id)
Executes a hotkey.
Definition: dispatcher.cpp:154
void disconnect_dispatcher(dispatcher *dispatcher)
Disconnects a dispatcher to the event handler.
Definition: handler.cpp:867
This file contains the definitions for the gui2::event::message class.
void connect_dispatcher(dispatcher *dispatcher)
Connects a dispatcher to the event handler.
Definition: handler.cpp:860
Callbacks with a sender aka notification messages.
void disconnect_signal(const F &func, const queue_position position=back_child)
Removes a callback from the appropriate queue based on event type.
Definition: dispatcher.hpp:372
std::string id
Text to match against addon_info.tags()
Definition: manager.cpp:215
bool wants_mouse_right_double_click() const
std::map< hotkey::HOTKEY_COMMAND, hotkey_function > hotkeys_
The registered hotkeys for this dispatcher.
Definition: dispatcher.hpp:613
bool connected_
Are we connected to the event handler.
Definition: dispatcher.hpp:610
Callbacks with the keyboard values (these haven&#39;t been determined yet).
void connect_signal(const F &func, const queue_position position=back_child)
Adds a callback to the appropriate queue based on event type.
Definition: dispatcher.hpp:353
Callbacks with a coordinate as extra parameter.
Holds a 2D point.
Definition: point.hpp:24
bool wants_mouse_left_double_click() const
dispatcher_callback< void * > signal_notification
Used for events in event_category::notification.
Definition: dispatcher.hpp:105
void connect_signal_on_draw(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a callback when the widget is drawn.
Definition: dispatcher.cpp:210
mouse_behavior
The behavior of the mouse events.
Definition: dispatcher.hpp:394
constexpr bool is_in_category(const ui_event event, const event_category mask)
Checks if a given event is in a given category.
Definition: handler.hpp:180
void connect_signal_pre_key_press(dispatcher &dispatcher, const signal_keyboard &signal)
Connects the signal for &#39;snooping&#39; on the keypress.
Definition: dispatcher.cpp:174
void disconnect()
Disconnects the dispatcher from the event handler.
Definition: dispatcher.cpp:58
void connect_signal_mouse_left_double_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button double click.
Definition: dispatcher.cpp:200
bool fire(const ui_event event, widget &target)
Fires an event which has no extra parameters.
Definition: dispatcher.cpp:76
void disconnect_signal_mouse_left_release(dispatcher &dispatcher, const signal &signal)
Disconnects a signal handler for a left mouse button release.
Definition: dispatcher.cpp:194
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
bool wants_mouse_middle_double_click() const
std::string::const_iterator iterator
Definition: tokenizer.hpp:25
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.
Definition: dispatcher.cpp:205
bool fire_event_double_click(dispatcher *dsp, widget *wgt, F &&... params)