From 814fe741eada8073c65055d3b6aad4cc8a3c4813 Mon Sep 17 00:00:00 2001 From: ZiRee Date: Wed, 8 Feb 2012 17:51:11 +0100 Subject: [PATCH] Hide default chatbar when user presses ESC while chatting and autohide is configured --- indra/newview/llnearbychatcontrol.cpp | 42 +++++++++++++++++++-------- indra/newview/llnearbychatcontrol.h | 5 ++++ 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/indra/newview/llnearbychatcontrol.cpp b/indra/newview/llnearbychatcontrol.cpp index 0752f53c67..2392a0213d 100644 --- a/indra/newview/llnearbychatcontrol.cpp +++ b/indra/newview/llnearbychatcontrol.cpp @@ -120,18 +120,7 @@ void LLNearbyChatControl::onCommit() LLNearbyChat::instance().sendChat(getConvertedText(),CHAT_TYPE_NORMAL); setText(LLStringExplicit("")); - if(getName()=="default_chat_bar") - { - if(gSavedSettings.getBOOL("CloseChatOnReturn")) - { - setFocus(FALSE); - } - - if(gSavedSettings.getBOOL("AutohideChatBar")) - { - LLNearbyChat::instance().showDefaultChatBar(FALSE); - } - } + autohide(); LLUICtrl::onCommit(); } @@ -246,3 +235,32 @@ void LLNearbyChatControl::setFocus(BOOL focus) LLNearbyChat::instance().setFocusedInputEditor(this,focus); LLLineEditor::setFocus(focus); } + +void LLNearbyChatControl::autohide() +{ + if(getName()=="default_chat_bar") + { + if(gSavedSettings.getBOOL("CloseChatOnReturn")) + { + setFocus(FALSE); + } + + if(gSavedSettings.getBOOL("AutohideChatBar")) + { + LLNearbyChat::instance().showDefaultChatBar(FALSE); + } + } +} + +// handle ESC key here +BOOL LLNearbyChatControl::handleKeyHere(KEY key, MASK mask ) +{ + // autohide the chat bar if escape key was pressed and we're the default chat bar + if(key==KEY_ESCAPE && mask==MASK_NONE) + { + autohide(); + gAgent.stopTyping(); + } + + return LLLineEditor::handleKeyHere(key,mask); +} diff --git a/indra/newview/llnearbychatcontrol.h b/indra/newview/llnearbychatcontrol.h index b351563748..a53e1bb447 100644 --- a/indra/newview/llnearbychatcontrol.h +++ b/indra/newview/llnearbychatcontrol.h @@ -42,6 +42,8 @@ public: virtual void onFocusLost(); virtual void setFocus(BOOL focus); + virtual BOOL handleKeyHere(KEY key,MASK mask); + static BOOL matchChatTypeTrigger(const std::string& in_str, std::string* out_str); private: @@ -50,6 +52,9 @@ private: // Chat data entered to be sent to nearby chat void onCommit(); + + // Unfocus and autohide chat bar accordingly if we are the default chat bar + void autohide(); }; #endif