From 273f57d5a2c993f88b204cbd59a65e1b3785caf8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 13 Apr 2013 04:58:30 +0200 Subject: [PATCH] Fix chat focus issues once and for all --- indra/llui/lluictrl.h | 2 +- indra/newview/llfloaterchat.cpp | 18 +++++++++++++++++- indra/newview/llfloaterchat.h | 2 ++ indra/newview/llimpanel.cpp | 20 ++++++++++++++++++++ indra/newview/llimpanel.h | 3 +++ 5 files changed, 43 insertions(+), 2 deletions(-) diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h index 69841a042..1e6146a3f 100644 --- a/indra/llui/lluictrl.h +++ b/indra/llui/lluictrl.h @@ -112,7 +112,7 @@ public: BOOL focusNextItem(BOOL text_entry_only); BOOL focusPrevItem(BOOL text_entry_only); - BOOL focusFirstItem(BOOL prefer_text_fields = FALSE, BOOL focus_flash = TRUE ); + virtual BOOL focusFirstItem(BOOL prefer_text_fields = FALSE, BOOL focus_flash = TRUE ); BOOL focusLastItem(BOOL prefer_text_fields = FALSE); // Non Virtuals diff --git a/indra/newview/llfloaterchat.cpp b/indra/newview/llfloaterchat.cpp index 60f67c1e0..c841278d3 100644 --- a/indra/newview/llfloaterchat.cpp +++ b/indra/newview/llfloaterchat.cpp @@ -187,7 +187,10 @@ void LLFloaterChat::handleVisibilityChange(BOOL new_visibility) // virtual void LLFloaterChat::onFocusReceived() { - gFocusMgr.setKeyboardFocus(getChildView("Chat Editor")); // Work around the chat bar no longer focusing from within the layout_stack + LLView* chat_editor = getChildView("Chat Editor"); + if (childIsVisible("Chat Editor")) + gFocusMgr.setKeyboardFocus(chat_editor); + LLFloater::onFocusReceived(); } @@ -740,3 +743,16 @@ void LLFloaterChat::hide(LLFloater* instance, const LLSD& key) VisibilityPolicy::hide(instance, key); } } + +BOOL LLFloaterChat::focusFirstItem(BOOL prefer_text_fields, BOOL focus_flash ) +{ + LLView* chat_editor = getChildView("Chat Editor"); + if (childIsVisible("Chat Editor")) + { + gFocusMgr.setKeyboardFocus(chat_editor); + return TRUE; + } + + return LLUICtrl::focusFirstItem(prefer_text_fields, focus_flash); +} + diff --git a/indra/newview/llfloaterchat.h b/indra/newview/llfloaterchat.h index e1626a9f3..3c7cbc4c5 100644 --- a/indra/newview/llfloaterchat.h +++ b/indra/newview/llfloaterchat.h @@ -98,6 +98,8 @@ public: LLPanelActiveSpeakers* mPanel; BOOL mScrolledToEnd; + BOOL focusFirstItem(BOOL prefer_text_fields = FALSE, BOOL focus_flash = TRUE ); + CachedUICtrl mToggleActiveSpeakersBtn; CachedUICtrl mChatPanel; }; diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp index 953f7c097..1ec2be0df 100644 --- a/indra/newview/llimpanel.cpp +++ b/indra/newview/llimpanel.cpp @@ -2606,3 +2606,23 @@ const bool LLFloaterIMPanel::isModerator(const LLUUID& speaker_id) return FALSE; } +BOOL LLFloaterIMPanel::focusFirstItem(BOOL prefer_text_fields, BOOL focus_flash ) +{ + LLView* chat_editor = getChildView("chat_editor"); + if (childIsVisible("chat_editor")) + { + gFocusMgr.setKeyboardFocus(chat_editor); + return TRUE; + } + + return LLUICtrl::focusFirstItem(prefer_text_fields, focus_flash); +} + +void LLFloaterIMPanel::onFocusReceived() +{ + LLView* chat_editor = getChildView("chat_editor"); + if (childIsVisible("chat_editor")) + gFocusMgr.setKeyboardFocus(chat_editor); + + LLFloater::onFocusReceived(); +} diff --git a/indra/newview/llimpanel.h b/indra/newview/llimpanel.h index 54a12c9d0..d8aac2be7 100644 --- a/indra/newview/llimpanel.h +++ b/indra/newview/llimpanel.h @@ -231,6 +231,9 @@ public: void *cargo_data, EAcceptance *accept, std::string& tooltip_msg); + BOOL focusFirstItem(BOOL prefer_text_fields = FALSE, BOOL focus_flash = TRUE ); + + void onFocusReceived(); void onInputEditorFocusReceived(); void onInputEditorFocusLost(); static void onInputEditorKeystroke(LLLineEditor* caller, void* userdata);