diff options
author | Andrew A. de Laix <alain@lindenlab.com> | 2011-08-29 13:27:17 -0500 |
---|---|---|
committer | Andrew A. de Laix <alain@lindenlab.com> | 2011-08-29 13:27:17 -0500 |
commit | 34a620523a7f4511c8f008f2e9a9428f41281480 (patch) | |
tree | 1f2aaef8b335e8db6303da42481fbe4634a7b236 | |
parent | 1d31559b30a32c4ebfde7dc2c42baef840be7c4d (diff) |
a better way to inject key events.
-rw-r--r-- | indra/newview/llwindowlistener.cpp | 27 | ||||
-rw-r--r-- | indra/newview/llwindowlistener.h | 6 |
2 files changed, 25 insertions, 8 deletions
diff --git a/indra/newview/llwindowlistener.cpp b/indra/newview/llwindowlistener.cpp index 3d756ef9b9..4cadc8773d 100644 --- a/indra/newview/llwindowlistener.cpp +++ b/indra/newview/llwindowlistener.cpp @@ -35,10 +35,11 @@ #include "llui.h" #include "llview.h" #include "llviewerwindow.h" +#include "llviewerkeyboard.h" #include "llrootview.h" #include <map> -LLWindowListener::LLWindowListener(LLWindowCallbacks *window, const KeyboardGetter& kbgetter) +LLWindowListener::LLWindowListener(LLViewerWindow *window, const KeyboardGetter& kbgetter) : LLEventAPI("LLWindow", "Inject input events into the LLWindow instance"), mWindow(window), mKbGetter(kbgetter) @@ -195,7 +196,8 @@ void LLWindowListener::keyDown(LLSD const & evt) gFocusMgr.setKeyboardFocus(target_view); KEY key = getKEY(evt); MASK mask = getMask(evt); - if (!target_view->handleKey(key, mask, true)) target_view->handleUnicodeChar(key, true); + gViewerKeyboard.handleKey(key, mask, false); + if(key < 0x80) mWindow->handleUnicodeChar(key, mask); } else { @@ -210,9 +212,24 @@ void LLWindowListener::keyDown(LLSD const & evt) void LLWindowListener::keyUp(LLSD const & evt) { - if (evt.has("path")) return; // LLView only handles key down. - - mKbGetter()->handleTranslatedKeyUp(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); + mKbGetter()->handleTranslatedKeyUp(getKEY(evt), getMask(evt)); + } + else + { + ; // TODO: Don't silently fail if target not available. + } + } + else + { + mKbGetter()->handleTranslatedKeyUp(getKEY(evt), getMask(evt)); + } } // for WhichButton diff --git a/indra/newview/llwindowlistener.h b/indra/newview/llwindowlistener.h index 74e577ff93..26adff35ff 100644 --- a/indra/newview/llwindowlistener.h +++ b/indra/newview/llwindowlistener.h @@ -31,13 +31,13 @@ #include <boost/function.hpp> class LLKeyboard; -class LLWindowCallbacks; +class LLViewerWindow; class LLWindowListener : public LLEventAPI { public: typedef boost::function<LLKeyboard*()> KeyboardGetter; - LLWindowListener(LLWindowCallbacks * window, const KeyboardGetter& kbgetter); + LLWindowListener(LLViewerWindow * window, const KeyboardGetter& kbgetter); void keyDown(LLSD const & evt); void keyUp(LLSD const & evt); @@ -47,7 +47,7 @@ public: void mouseScroll(LLSD const & evt); private: - LLWindowCallbacks * mWindow; + LLViewerWindow * mWindow; KeyboardGetter mKbGetter; }; |