widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #13399
[Merge] lp:~widelands-dev/widelands/bug-1627374-chat-input into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1627374-chat-input into lp:widelands.
Commit message:
Remove focus from editbox in gamechatpanel when it minimizes
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1627374 in widelands: "Chat window is still focused when minimized"
https://bugs.launchpad.net/widelands/+bug/1627374
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1627374-chat-input/+merge/345457
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1627374-chat-input into lp:widelands.
=== modified file 'src/ui_basic/window.h'
--- src/ui_basic/window.h 2018-04-07 16:59:00 +0000
+++ src/ui_basic/window.h 2018-05-12 08:29:49 +0000
@@ -80,8 +80,8 @@
bool is_minimal() const {
return is_minimal_;
}
- void restore();
- void minimize();
+ virtual void restore();
+ virtual void minimize();
bool is_snap_target() const override {
return true;
}
=== modified file 'src/wui/game_chat_menu.cc'
--- src/wui/game_chat_menu.cc 2018-04-07 16:59:00 +0000
+++ src/wui/game_chat_menu.cc 2018-05-12 08:29:49 +0000
@@ -34,11 +34,11 @@
ChatProvider& chat,
const std::string& title)
: UI::UniqueWindow(parent, "chat", ®istry, 440, 235, title),
- chat_(this, 5, 5, get_inner_w() - 10, get_inner_h() - 10, chat) {
- if (get_usedefaultpos())
+ chat_(this, 5, 5, get_inner_w() - 10, get_inner_h() - 10, chat), close_on_send_(false) {
+ if (get_usedefaultpos()) {
center_to_parent();
-
- close_on_send_ = false;
+ }
+ set_can_focus(true);
chat_.sent.connect(boost::bind(&GameChatMenu::acknowledge, this));
chat_.aborted.connect(boost::bind(&GameChatMenu::acknowledge, this));
@@ -63,7 +63,18 @@
close_on_send_ = close_on_send;
}
+void GameChatMenu::restore() {
+ Window::restore();
+ chat_.focus_edit();
+}
+
+void GameChatMenu::minimize() {
+ Window::minimize();
+ chat_.unfocus_edit();
+}
+
void GameChatMenu::acknowledge() {
- if (close_on_send_)
+ if (close_on_send_) {
die();
+ }
}
=== modified file 'src/wui/game_chat_menu.h'
--- src/wui/game_chat_menu.h 2018-04-07 16:59:00 +0000
+++ src/wui/game_chat_menu.h 2018-05-12 08:29:49 +0000
@@ -49,6 +49,9 @@
private:
GameChatMenu(UI::Panel*, UI::UniqueWindow::Registry&, ChatProvider&, const std::string& title);
+
+ void restore() override;
+ void minimize() override;
void acknowledge();
GameChatPanel chat_;
bool close_on_send_;
=== modified file 'src/wui/gamechatpanel.cc'
--- src/wui/gamechatpanel.cc 2018-05-02 19:26:52 +0000
+++ src/wui/gamechatpanel.cc 2018-05-12 08:29:49 +0000
@@ -93,9 +93,18 @@
* Put the focus on the message input panel.
*/
void GameChatPanel::focus_edit() {
+ editbox.set_can_focus(true);
editbox.focus();
}
+/**
+ * Remove the focus from the message input panel.
+ */
+void GameChatPanel::unfocus_edit() {
+ editbox.set_can_focus(false);
+}
+
+
void GameChatPanel::key_enter() {
const std::string& str = editbox.text();
=== modified file 'src/wui/gamechatpanel.h'
--- src/wui/gamechatpanel.h 2018-04-21 14:15:48 +0000
+++ src/wui/gamechatpanel.h 2018-05-12 08:29:49 +0000
@@ -49,6 +49,7 @@
}
void focus_edit();
+ void unfocus_edit();
private:
void recalculate();
Follow ups