From fd42029a615475adaf13b8f5d6e535f28d209366 Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Tue, 22 Oct 2013 23:35:53 -0400 Subject: [PATCH] LLViewerWindow::handleKey(): Partial Fix for Issue 704: Keyboard shortcuts that should be passed to focused text fields are instead passed to selected prims when building All edit keys now work, but Ctrl-A still doesn't work right, it must be grabbed by something else... Adds LLFocusMgr::keyboardFocusHasAccelerators() Adds virtual bool LLView::hasAccelerators() which returns false by default, overrides returning true placed in LLPreviewScript and LLPreviewNotecard Shortcut keys added to notecard and script menu xmls I'm thinking Qarl's Align tool handling may be receiving the Ctrl-A, we do seem to handle it differently than Exodus and Firestorm something modern could have broken the old way.. Come to think of it, those two features(Align and Select all prims) have a longstanding shortcut conflict in shortcuts... that's pretty nasty --- indra/llui/llfocusmgr.cpp | 14 ++++++ indra/llui/llfocusmgr.h | 1 + indra/llui/llview.h | 5 +++ indra/newview/llpreviewnotecard.h | 1 + indra/newview/llpreviewscript.h | 2 + indra/newview/llviewerwindow.cpp | 4 +- .../xui/en-us/floater_preview_notecard.xml | 36 ++++++---------- .../floater_preview_notecard_keep_discard.xml | 36 ++++++---------- .../xui/en-us/floater_script_ed_panel.xml | 43 ++++++------------- 9 files changed, 63 insertions(+), 79 deletions(-) diff --git a/indra/llui/llfocusmgr.cpp b/indra/llui/llfocusmgr.cpp index 7817fd0d5..e5242f7db 100644 --- a/indra/llui/llfocusmgr.cpp +++ b/indra/llui/llfocusmgr.cpp @@ -366,6 +366,20 @@ void LLFocusMgr::removeKeyboardFocusWithoutCallback( const LLFocusableElement* f } } +bool LLFocusMgr::keyboardFocusHasAccelerators() const +{ + LLView* focus_view = dynamic_cast(mKeyboardFocus); + while(focus_view) + { + if (focus_view->hasAccelerators()) + { + return true; + } + + focus_view = focus_view->getParent(); + } + return false; +} void LLFocusMgr::setMouseCapture( LLMouseHandler* new_captor ) { diff --git a/indra/llui/llfocusmgr.h b/indra/llui/llfocusmgr.h index 5f1466f5d..7e5e50dfb 100644 --- a/indra/llui/llfocusmgr.h +++ b/indra/llui/llfocusmgr.h @@ -121,6 +121,7 @@ public: void unlockFocus(); BOOL focusLocked() const { return mLockedView != NULL; } + bool keyboardFocusHasAccelerators() const; struct Impl; diff --git a/indra/llui/llview.h b/indra/llui/llview.h index b009bab41..cc7ce21eb 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -357,6 +357,11 @@ public: BOOL focusNextRoot(); BOOL focusPrevRoot(); + // Normally we want the app menus to get priority on accelerated keys + // However, sometimes we want to give specific views a first chance + // at handling them. (eg. the script editor) + virtual bool hasAccelerators() const { return false; } + virtual void deleteAllChildren(); virtual void setTentative(BOOL b); diff --git a/indra/newview/llpreviewnotecard.h b/indra/newview/llpreviewnotecard.h index 442673c0c..6ea6e1ba8 100644 --- a/indra/newview/llpreviewnotecard.h +++ b/indra/newview/llpreviewnotecard.h @@ -66,6 +66,7 @@ public: // llview virtual void draw(); + virtual bool hasAccelerators() const { return true; } virtual BOOL handleKeyHere(KEY key, MASK mask); virtual void setEnabled( BOOL enabled ); virtual void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index ace3f9949..906708333 100644 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -128,6 +128,8 @@ public: static BOOL enableSelectAllMenu(void* userdata); static BOOL enableDeselectMenu(void* userdata); + virtual bool hasAccelerators() const { return true; } + private: static bool onHelpWebDialog(const LLSD& notification, const LLSD& response); static void onBtnHelp(void* userdata); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 03b3cd673..7ea6c9890 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -2723,7 +2723,6 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask) LLFocusableElement* keyboard_focus = gFocusMgr.getKeyboardFocus(); - /* // give menus a chance to handle modified (Ctrl, Alt) shortcut keys before current focus // as long as focus isn't locked if (mask & (MASK_CONTROL | MASK_ALT) && !gFocusMgr.focusLocked()) @@ -2736,13 +2735,14 @@ BOOL LLViewerWindow::handleKey(KEY key, MASK mask) return TRUE; } + /* Singu Note: This caused a bug where the menu ate keys before parents of keyboard_focus for some reason, breaking multifloaters usage of ctrl-w to close their selected child floater if ((gMenuBarView && gMenuBarView->handleAcceleratorKey(key, mask)) || (gLoginMenuBarView && gLoginMenuBarView->handleAcceleratorKey(key, mask))) { return TRUE; } + */ } - */ // give floaters first chance to handle TAB key // so frontmost floater gets focus diff --git a/indra/newview/skins/default/xui/en-us/floater_preview_notecard.xml b/indra/newview/skins/default/xui/en-us/floater_preview_notecard.xml index 5307864c6..90a0a592e 100644 --- a/indra/newview/skins/default/xui/en-us/floater_preview_notecard.xml +++ b/indra/newview/skins/default/xui/en-us/floater_preview_notecard.xml @@ -24,30 +24,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - + + - - - - - - - - - - - - + + + + + + + + + + + +