The Battle for Wesnoth  1.19.7+dev
hotkey_bind.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2016 - 2024
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #define GETTEXT_DOMAIN "wesnoth-lib"
16 
18 
19 #include "gui/widgets/window.hpp"
20 
21 
22 namespace gui2::dialogs
23 {
24 
25 REGISTER_DIALOG(hotkey_bind)
26 
27 hotkey_bind::hotkey_bind(const std::string& hotkey_id)
28  : modal_dialog(window_id())
29  , hotkey_id_(hotkey_id)
30  , new_binding_()
31 {
32 }
33 
35 {
36  connect_signal<event::SDL_RAW_EVENT>(
37  std::bind(&hotkey_bind::sdl_event_callback, this, std::placeholders::_5),
39 }
40 
41 void hotkey_bind::sdl_event_callback(const SDL_Event &event)
42 {
43  if (hotkey::is_hotkeyable_event(event)) {
45  }
46  if(new_binding_) {
48  }
49 }
50 
51 
52 } // namespace dialogs
hotkey::hotkey_ptr new_binding_
Definition: hotkey_bind.hpp:39
const std::string & hotkey_id_
Definition: hotkey_bind.hpp:37
void sdl_event_callback(const SDL_Event &event)
Definition: hotkey_bind.cpp:41
virtual void pre_show() override
Actions to be taken before showing the window.
Definition: hotkey_bind.cpp:34
Abstract base class for all modal dialogs.
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
Definition: window.hpp:394
This file contains the window object, this object is a top level container which has the event manage...
REGISTER_DIALOG(editor_edit_unit)
@ OK
Dialog was closed with the OK button.
Definition: retval.hpp:35
hotkey_ptr create_hotkey(const std::string &id, const SDL_Event &event)
Create a new hotkey item for a command from an SDL_Event.
bool is_hotkeyable_event(const SDL_Event &event)