From 196e9d6c78410596ad27816c0e1de722292e7527 Mon Sep 17 00:00:00 2001 From: Siana Gearz Date: Sun, 25 Mar 2012 09:29:55 +0200 Subject: [PATCH] Unbreaking Ctrl+W the right way --- indra/llui/llfloater.cpp | 34 ++++------------------------------ indra/llui/llfloater.h | 1 - indra/llui/llmultifloater.cpp | 16 ++++++++++++++++ indra/llui/llmultifloater.h | 1 + indra/newview/llimpanel.cpp | 4 +++- 5 files changed, 24 insertions(+), 32 deletions(-) diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp index 3145c3cf1..08924ac11 100644 --- a/indra/llui/llfloater.cpp +++ b/indra/llui/llfloater.cpp @@ -1202,6 +1202,7 @@ BOOL LLFloater::handleMiddleMouseDown(S32 x, S32 y, MASK mask) return LLPanel::handleMiddleMouseDown( x, y, mask ); } + // virtual BOOL LLFloater::handleDoubleClick(S32 x, S32 y, MASK mask) { @@ -1210,22 +1211,6 @@ BOOL LLFloater::handleDoubleClick(S32 x, S32 y, MASK mask) return was_minimized || LLPanel::handleDoubleClick(x, y, mask); } -// virtual -BOOL LLFloater::handleKeyHere(KEY key, MASK mask) -{ - if (key == 'W' && mask == MASK_CONTROL) - { - if (canClose() && isCloseable()) - { - close(); - } - return TRUE; - } - - return LLPanel::handleKeyHere(key, mask); -} - - void LLFloater::bringToFront( S32 x, S32 y ) { if (getVisible() && pointInView(x, y)) @@ -1352,21 +1337,10 @@ void LLFloater::onClickEdit(void *userdata) // static LLFloater* LLFloater::getClosableFloaterFromFocus() { - LLFloater* focused_floater = NULL; + LLFloater* focused_floater = gFloaterView->getFocusedFloater(); - handle_map_iter_t iter; - for(iter = sFloaterMap.begin(); iter != sFloaterMap.end(); ++iter) + if (!focused_floater) { - focused_floater = iter->second; - if (focused_floater->hasFocus()) - { - break; - } - } - - if (iter == sFloaterMap.end()) - { - // nothing found, return return NULL; } @@ -1374,7 +1348,7 @@ LLFloater* LLFloater::getClosableFloaterFromFocus() // Find and close a parental floater that is closeable, if any. LLFloater* previous_floater = NULL; // Guard against endless loop, because getParentFloater(x) can return x! for(LLFloater* floater_to_close = focused_floater; - NULL != floater_to_close && floater_to_close != gFloaterView->getParentFloater(floater_to_close); + NULL != floater_to_close; floater_to_close = gFloaterView->getParentFloater(floater_to_close)) { if(floater_to_close == previous_floater) diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h index 40d8c7ecd..939071b0f 100644 --- a/indra/llui/llfloater.h +++ b/indra/llui/llfloater.h @@ -197,7 +197,6 @@ public: virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask); virtual BOOL handleMiddleMouseDown(S32 x, S32 y, MASK mask); - /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask); virtual void draw(); virtual void onOpen() {} diff --git a/indra/llui/llmultifloater.cpp b/indra/llui/llmultifloater.cpp index 92823fd33..29ea32816 100644 --- a/indra/llui/llmultifloater.cpp +++ b/indra/llui/llmultifloater.cpp @@ -406,6 +406,22 @@ void LLMultiFloater::setVisible(BOOL visible) } } +BOOL LLMultiFloater::handleKeyHere(KEY key, MASK mask) +{ + if (key == 'W' && mask == MASK_CONTROL) + { + LLFloater* floater = getActiveFloater(); + // is user closeable and is system closeable + if (floater && floater->canClose() && floater->isCloseable()) + { + floater->close(); + } + return TRUE; + } + + return LLFloater::handleKeyHere(key, mask); +} + LLFloater* LLMultiFloater::getActiveFloater() { return (LLFloater*)mTabContainer->getCurrentPanel(); diff --git a/indra/llui/llmultifloater.h b/indra/llui/llmultifloater.h index ccf5f462f..29c03b3c4 100644 --- a/indra/llui/llmultifloater.h +++ b/indra/llui/llmultifloater.h @@ -51,6 +51,7 @@ public: /*virtual*/ void onClose(bool app_quitting); /*virtual*/ void draw(); /*virtual*/ void setVisible(BOOL visible); + /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask); virtual void setCanResize(BOOL can_resize); virtual void growToFit(S32 content_width, S32 content_height); diff --git a/indra/newview/llimpanel.cpp b/indra/newview/llimpanel.cpp index 56375829a..e1c3ab443 100644 --- a/indra/newview/llimpanel.cpp +++ b/indra/newview/llimpanel.cpp @@ -1788,7 +1788,9 @@ BOOL LLFloaterIMPanel::handleKeyHere( KEY key, MASK mask ) } } - return handled || LLFloater::handleKeyHere(key, mask); + // May need to call base class LLPanel::handleKeyHere if not handled + // in order to tab between buttons. JNC 1.2.2002 + return handled; } BOOL LLFloaterIMPanel::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,