summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorAndrew A. de Laix <alain@lindenlab.com>2011-08-26 15:06:14 -0500
committerAndrew A. de Laix <alain@lindenlab.com>2011-08-26 15:06:14 -0500
commit1d31559b30a32c4ebfde7dc2c42baef840be7c4d (patch)
tree9c1a4f015f1d0e16ce41d45d3844ec78aa0661b8 /indra
parent79f14b7febf512e96a7d63eff8e6db895a7e72cf (diff)
implement path option for key events.
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llwindowlistener.cpp37
1 files changed, 33 insertions, 4 deletions
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 <map>
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));
}