GUI2/Chatbox: allow keyboard focus
This commit is contained in:
parent
b91f3a6cf8
commit
7c29cbe89e
2 changed files with 21 additions and 0 deletions
|
@ -44,6 +44,8 @@ static lg::log_domain log_lobby("lobby");
|
|||
#define LOG_LB LOG_STREAM(info, log_lobby)
|
||||
#define ERR_LB LOG_STREAM(err, log_lobby)
|
||||
|
||||
#define LOG_SCOPE_HEADER get_control_type() + " [" + id() + "] " + __func__
|
||||
#define LOG_HEADER LOG_SCOPE_HEADER + ':'
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
|
@ -62,6 +64,14 @@ chatbox::chatbox(const implementation::builder_chatbox& builder)
|
|||
, lobby_info_(nullptr)
|
||||
, wesnothd_connection_(nullptr)
|
||||
{
|
||||
// We only implement a RECEIVE_KEYBOARD_FOCUS handler; LOSE_KEYBOARD_FOCUS
|
||||
// isn't needed. This handler forwards focus to the input textbox, meaning
|
||||
// if keyboard_focus is called on a chatbox, distributor::keyboard_focus_
|
||||
// will immediately be set to the input textbox, which will then handle focus
|
||||
// loss itself when applicable. Nothing else happens in the interim while
|
||||
// keyboard_focus_ equals `this` to warrent cleanup.
|
||||
connect_signal<event::RECEIVE_KEYBOARD_FOCUS>(
|
||||
std::bind(&chatbox::signal_handler_receive_keyboard_focus, this, _2));
|
||||
}
|
||||
|
||||
void chatbox::finalize_setup()
|
||||
|
@ -723,6 +733,14 @@ void chatbox::process_network_data(const ::config& data)
|
|||
}
|
||||
}
|
||||
|
||||
void chatbox::signal_handler_receive_keyboard_focus(const event::ui_event event)
|
||||
{
|
||||
DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";
|
||||
|
||||
// Forward focus to the input textbox.
|
||||
get_window()->keyboard_capture(chat_input_);
|
||||
}
|
||||
|
||||
// }---------- DEFINITION ---------{
|
||||
|
||||
chatbox_definition::chatbox_definition(const config& cfg)
|
||||
|
|
|
@ -246,6 +246,9 @@ public:
|
|||
void process_message(const ::config& data, bool whisper = false);
|
||||
|
||||
void process_network_data(const ::config& data);
|
||||
|
||||
private:
|
||||
void signal_handler_receive_keyboard_focus(const event::ui_event event);
|
||||
};
|
||||
|
||||
// }---------- DEFINITION ---------{
|
||||
|
|
Loading…
Add table
Reference in a new issue