From 1d31559b30a32c4ebfde7dc2c42baef840be7c4d Mon Sep 17 00:00:00 2001 From: "Andrew A. de Laix" Date: Fri, 26 Aug 2011 15:06:14 -0500 Subject: implement path option for key events. --- indra/newview/llwindowlistener.cpp | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'indra') diff --git a/indra/newview/llwindowlistener.cpp b/indra/newview/llwindowlistener.cpp index e5deaa42cf..3d756ef9b9 100644 --- a/indra/newview/llwindowlistener.cpp +++ b/indra/newview/llwindowlistener.cpp @@ -29,9 +29,13 @@ #include "llwindowlistener.h" #include "llcoord.h" +#include "llfocusmgr.h" #include "llkeyboard.h" #include "llwindowcallbacks.h" #include "llui.h" +#include "llview.h" +#include "llviewerwindow.h" +#include "llrootview.h" #include LLWindowListener::LLWindowListener(LLWindowCallbacks *window, const KeyboardGetter& kbgetter) @@ -117,8 +121,10 @@ protected: } }; +namespace { + // helper for getMask() -static MASK lookupMask_(const std::string& maskname) +MASK lookupMask_(const std::string& maskname) { // It's unclear to me whether MASK_MAC_CONTROL is important, but it's not // supported by maskFromString(). Handle that specially. @@ -136,7 +142,7 @@ static MASK lookupMask_(const std::string& maskname) } } -static MASK getMask(const LLSD& event) +MASK getMask(const LLSD& event) { LLSD masknames(event["mask"]); if (! masknames.isArray()) @@ -156,7 +162,7 @@ static MASK getMask(const LLSD& event) return mask; } -static KEY getKEY(const LLSD& event) +KEY getKEY(const LLSD& event) { if (event.has("keysym")) { @@ -176,13 +182,36 @@ static KEY getKEY(const LLSD& event) } } +} // namespace + void LLWindowListener::keyDown(LLSD const & evt) { - mKbGetter()->handleTranslatedKeyDown(getKEY(evt), getMask(evt)); + if (evt.has("path")) + { + LLView * target_view = + LLUI::resolvePath(gViewerWindow->getRootView(), evt["path"]); + if ((target_view != 0) && target_view->isAvailable()) + { + gFocusMgr.setKeyboardFocus(target_view); + KEY key = getKEY(evt); + MASK mask = getMask(evt); + if (!target_view->handleKey(key, mask, true)) target_view->handleUnicodeChar(key, true); + } + else + { + ; // TODO: Don't silently fail if target not available. + } + } + else + { + mKbGetter()->handleTranslatedKeyDown(getKEY(evt), getMask(evt)); + } } void LLWindowListener::keyUp(LLSD const & evt) { + if (evt.has("path")) return; // LLView only handles key down. + mKbGetter()->handleTranslatedKeyUp(getKEY(evt), getMask(evt)); } -- cgit v1.2.3