浏览代码

Merge pull request #2996 from Nordsoft91/fix-2992

Capture key event in chat box
Ivan Savenko 2 年之前
父节点
当前提交
56d5c74a61
共有 2 个文件被更改,包括 6 次插入0 次删除
  1. 5 0
      client/lobby/CSelectionBase.cpp
  2. 1 0
      client/lobby/CSelectionBase.h

+ 5 - 0
client/lobby/CSelectionBase.cpp

@@ -327,6 +327,11 @@ CChatBox::CChatBox(const Rect & rect)
 	chatHistory->label->color = Colors::GREEN;
 }
 
+bool CChatBox::captureThisKey(EShortcut key)
+{
+	return !inputBox->getText().empty() && key == EShortcut::GLOBAL_ACCEPT;
+}
+
 void CChatBox::keyPressed(EShortcut key)
 {
 	if(key == EShortcut::GLOBAL_ACCEPT && inputBox->getText().size())

+ 1 - 0
client/lobby/CSelectionBase.h

@@ -122,6 +122,7 @@ public:
 	CChatBox(const Rect & rect);
 
 	void keyPressed(EShortcut key) override;
+	bool captureThisKey(EShortcut key) override;
 	void addNewMessage(const std::string & text);
 };