From ca49ad736a06aa796610f068f6419c39b8535251 Mon Sep 17 00:00:00 2001 From: callum_linden Date: Fri, 10 Jul 2015 01:01:07 +0100 Subject: Initial support for keyboard (in progress) but includes many viewer changes to plumb in Key Up events --- indra/llui/llfocusmgr.cpp | 6 ++++++ indra/llui/llfocusmgr.h | 1 + indra/llui/llview.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ indra/llui/llview.h | 3 +++ 4 files changed, 56 insertions(+) (limited to 'indra/llui') diff --git a/indra/llui/llfocusmgr.cpp b/indra/llui/llfocusmgr.cpp index 547f0bd398..fb811452be 100755 --- a/indra/llui/llfocusmgr.cpp +++ b/indra/llui/llfocusmgr.cpp @@ -46,6 +46,12 @@ BOOL LLFocusableElement::handleKey(KEY key, MASK mask, BOOL called_from_parent) return FALSE; } +// virtual +BOOL LLFocusableElement::handleKeyUp(KEY key, MASK mask, BOOL called_from_parent) +{ + return FALSE; +} + // virtual BOOL LLFocusableElement::handleUnicodeChar(llwchar uni_char, BOOL called_from_parent) { diff --git a/indra/llui/llfocusmgr.h b/indra/llui/llfocusmgr.h index afd2a8ce06..950ac55325 100755 --- a/indra/llui/llfocusmgr.h +++ b/indra/llui/llfocusmgr.h @@ -57,6 +57,7 @@ public: // These were brought up the hierarchy from LLView so that we don't have to use dynamic_cast when dealing with keyboard focus. virtual BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent); + virtual BOOL handleKeyUp(KEY key, MASK mask, BOOL called_from_parent); virtual BOOL handleUnicodeChar(llwchar uni_char, BOOL called_from_parent); virtual void onTopLost(); // called when registered as top ctrl and user clicks elsewhere diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index a8beb9cfc9..8f7cac1f61 100755 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -866,6 +866,7 @@ BOOL LLView::handleToolTip(S32 x, S32 y, MASK mask) return handled; } + BOOL LLView::handleKey(KEY key, MASK mask, BOOL called_from_parent) { BOOL handled = FALSE; @@ -898,6 +899,38 @@ BOOL LLView::handleKey(KEY key, MASK mask, BOOL called_from_parent) return handled; } +BOOL LLView::handleKeyUp(KEY key, MASK mask, BOOL called_from_parent) +{ + BOOL handled = FALSE; + + if (getVisible() && getEnabled()) + { + if (called_from_parent) + { + // Downward traversal + handled = childrenHandleKeyUp(key, mask) != NULL; + } + + if (!handled) + { + // For event logging we don't care which widget handles it + // So we capture the key at the end of this function once we know if it was handled + handled = handleKeyUpHere(key, mask); + if (handled) + { + LL_DEBUGS() << "Key handled by " << getName() << LL_ENDL; + } + } + } + + if (!handled && !called_from_parent && mParentView) + { + // Upward traversal + handled = mParentView->handleKeyUp(key, mask, FALSE); + } + return handled; +} + // Called from handleKey() // Handles key in this object. Checking parents and children happens in handleKey() BOOL LLView::handleKeyHere(KEY key, MASK mask) @@ -905,6 +938,13 @@ BOOL LLView::handleKeyHere(KEY key, MASK mask) return FALSE; } +// Called from handleKey() +// Handles key in this object. Checking parents and children happens in handleKey() +BOOL LLView::handleKeyUpHere(KEY key, MASK mask) +{ + return FALSE; +} + BOOL LLView::handleUnicodeChar(llwchar uni_char, BOOL called_from_parent) { BOOL handled = FALSE; @@ -1020,6 +1060,12 @@ LLView* LLView::childrenHandleKey(KEY key, MASK mask) return childrenHandleCharEvent("Key", &LLView::handleKey, key, mask); } +// Called during downward traversal +LLView* LLView::childrenHandleKeyUp(KEY key, MASK mask) +{ + return childrenHandleCharEvent("Key Up", &LLView::handleKeyUp, key, mask); +} + // Called during downward traversal LLView* LLView::childrenHandleUnicodeChar(llwchar uni_char) { diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 7861c8f729..8494bb338a 100755 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -378,6 +378,7 @@ public: // inherited from LLFocusableElement /* virtual */ BOOL handleKey(KEY key, MASK mask, BOOL called_from_parent); + /* virtual */ BOOL handleKeyUp(KEY key, MASK mask, BOOL called_from_parent); /* virtual */ BOOL handleUnicodeChar(llwchar uni_char, BOOL called_from_parent); virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, @@ -509,6 +510,7 @@ public: //virtual BOOL addChildFromParam(const LLInitParam::BaseBlock& params) { return TRUE; } virtual BOOL handleKeyHere(KEY key, MASK mask); + virtual BOOL handleKeyUpHere(KEY key, MASK mask); virtual BOOL handleUnicodeCharHere(llwchar uni_char); virtual void handleReshape(const LLRect& rect, bool by_user); @@ -538,6 +540,7 @@ protected: void logMouseEvent(); LLView* childrenHandleKey(KEY key, MASK mask); + LLView* childrenHandleKeyUp(KEY key, MASK mask); LLView* childrenHandleUnicodeChar(llwchar uni_char); LLView* childrenHandleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, -- cgit v1.2.3 From 9833a50260fb45d5f0033200ae756834c0cc9940 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 27 Oct 2015 15:17:12 -0700 Subject: MAINT-5754: For MoaP and MediaCtrls forward all events including KEYUP and KEYDOWN to the CEF plugin. --- indra/llui/llfocusmgr.cpp | 12 ++++++++++++ indra/llui/llfocusmgr.h | 8 ++++++++ 2 files changed, 20 insertions(+) (limited to 'indra/llui') diff --git a/indra/llui/llfocusmgr.cpp b/indra/llui/llfocusmgr.cpp index fb811452be..1a51b96fdf 100755 --- a/indra/llui/llfocusmgr.cpp +++ b/indra/llui/llfocusmgr.cpp @@ -58,6 +58,18 @@ BOOL LLFocusableElement::handleUnicodeChar(llwchar uni_char, BOOL called_from_pa return FALSE; } +// virtual +bool LLFocusableElement::wantsKeyUpKeyDown() const +{ + return false; +} + +//virtual +bool LLFocusableElement::wantsReturnKey() const +{ + return false; +} + // virtual LLFocusableElement::~LLFocusableElement() { diff --git a/indra/llui/llfocusmgr.h b/indra/llui/llfocusmgr.h index 950ac55325..0e3d7d8e59 100755 --- a/indra/llui/llfocusmgr.h +++ b/indra/llui/llfocusmgr.h @@ -60,6 +60,14 @@ public: virtual BOOL handleKeyUp(KEY key, MASK mask, BOOL called_from_parent); virtual BOOL handleUnicodeChar(llwchar uni_char, BOOL called_from_parent); + /** + * If true this LLFocusableElement wants to receive KEYUP and KEYDOWN messages + * even for normal character strokes. + * Default implementation returns false. + */ + virtual bool wantsKeyUpKeyDown() const; + virtual bool wantsReturnKey() const; + virtual void onTopLost(); // called when registered as top ctrl and user clicks elsewhere protected: virtual void onFocusReceived(); -- cgit v1.2.3