diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp index 13b8a6fa7d..a39699f286 100644 --- a/indra/newview/llnearbychat.cpp +++ b/indra/newview/llnearbychat.cpp @@ -61,6 +61,7 @@ #include "llimfloatercontainer.h" #include "llimfloater.h" +#include "lllineeditor.h" static const S32 RESIZE_BAR_THICKNESS = 3; @@ -144,6 +145,23 @@ BOOL LLNearbyChat::postBuild() return true; } + mInputEditor = getChild("chat_box"); + mInputEditor->setMaxTextLength(1023); + // enable line history support for instant message bar + mInputEditor->setEnableLineHistory(TRUE); + + + mInputEditor->setFocusReceivedCallback( boost::bind(onInputEditorFocusReceived, _1, this) ); + mInputEditor->setFocusLostCallback( boost::bind(onInputEditorFocusLost, _1, this) ); + mInputEditor->setKeystrokeCallback( onInputEditorKeystroke, this ); + mInputEditor->setCommitOnFocusLost( FALSE ); + mInputEditor->setRevertOnEsc( FALSE ); + mInputEditor->setReplaceNewlinesWithSpaces( FALSE ); + mInputEditor->setPassDelete( TRUE ); + + childSetCommitCallback("chat_box", onSendMsg, this); + + mTypingStart = LLTrans::getString("IM_typing_start_string"); void LLNearbyChat::applySavedVariables() { @@ -359,7 +377,35 @@ bool isWordsName(const std::string& name) return std::string::npos != pos && name.rfind(' ', name.length()) == pos && 0 != pos && name.length()-1 != pos; } } - +void LLNearbyChat::onInputEditorFocusReceived( LLFocusableElement* caller, void* userdata ) +{ + LLNearbyChat* self= (LLNearbyChat*) userdata; +} +void LLNearbyChat::onInputEditorFocusLost(LLFocusableElement* caller, void* userdata) +{ + LLNearbyChat* self = (LLNearbyChat*) userdata; + self->setTyping(false); +} +void LLNearbyChat::onInputEditorKeystroke(LLLineEditor* caller, void* userdata) +{ + LLNearbyChat* self = (LLNearbyChat*)userdata; + std::string text = self->mInputEditor->getText(); + if (!text.empty()) + { + self->setTyping(true); + } + else + { + // Deleting all text counts as stopping typing. + self->setTyping(false); + } +} +void LLNearbyChat::onSendMsg( LLUICtrl* ctrl, void* userdata ) +{ + LLNearbyChat* self = (LLNearbyChat*) userdata; + llinfos << "DEBUG: Sending message" << llendl; + self->setTyping(false); +} void LLNearbyChat::loadHistory() { LLSD do_not_log; diff --git a/indra/newview/llnearbychat.h b/indra/newview/llnearbychat.h index 917bcac682..a4e03f291b 100644 --- a/indra/newview/llnearbychat.h +++ b/indra/newview/llnearbychat.h @@ -33,6 +33,7 @@ class LLResizeBar; class LLChatHistory; +class LLLineEditor; class LLNearbyChat: public LLDockableFloater { @@ -73,6 +74,8 @@ public: void setDocked(bool docked, bool pop_on_undock = true); BOOL getVisible(); + static void onSendMsg( LLUICtrl*, void*); + void sendMsg(); private: virtual void applySavedVariables(); @@ -81,12 +84,17 @@ private: void onNearbySpeakers (); + void setTyping(bool typing); + static void onInputEditorFocusReceived( LLFocusableElement* caller, void* userdata ); + static void onInputEditorFocusLost(LLFocusableElement* caller, void* userdata); + static void onInputEditorKeystroke(LLLineEditor* caller, void* userdata); private: LLHandle mPopupMenuHandle; LLChatHistory* mChatHistory; - + std::vector mMessageArchive; + LLLineEditor* mInputEditor; }; #endif