aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llfocusmgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llui/llfocusmgr.cpp84
1 files changed, 75 insertions, 9 deletions
diff --git a/linden/indra/llui/llfocusmgr.cpp b/linden/indra/llui/llfocusmgr.cpp
index 661ffdd..96b01b9 100644
--- a/linden/indra/llui/llfocusmgr.cpp
+++ b/linden/indra/llui/llfocusmgr.cpp
@@ -38,6 +38,68 @@
38 38
39const F32 FOCUS_FADE_TIME = 0.3f; 39const F32 FOCUS_FADE_TIME = 0.3f;
40 40
41// NOTE: the LLFocusableElement implementation has been here from lluictrl.cpp.
42
43LLFocusableElement::LLFocusableElement()
44: mFocusLostCallback(NULL),
45 mFocusReceivedCallback(NULL),
46 mFocusChangedCallback(NULL),
47 mFocusCallbackUserData(NULL)
48{
49}
50
51// virtual
52BOOL LLFocusableElement::handleKey(KEY key, MASK mask, BOOL called_from_parent)
53{
54 return FALSE;
55}
56
57// virtual
58BOOL LLFocusableElement::handleUnicodeChar(llwchar uni_char, BOOL called_from_parent)
59{
60 return FALSE;
61}
62
63// virtual
64LLFocusableElement::~LLFocusableElement()
65{
66}
67
68void LLFocusableElement::onFocusReceived()
69{
70 if( mFocusReceivedCallback )
71 {
72 mFocusReceivedCallback( this, mFocusCallbackUserData );
73 }
74 if( mFocusChangedCallback )
75 {
76 mFocusChangedCallback( this, mFocusCallbackUserData );
77 }
78}
79
80void LLFocusableElement::onFocusLost()
81{
82 if( mFocusLostCallback )
83 {
84 mFocusLostCallback( this, mFocusCallbackUserData );
85 }
86
87 if( mFocusChangedCallback )
88 {
89 mFocusChangedCallback( this, mFocusCallbackUserData );
90 }
91}
92
93BOOL LLFocusableElement::hasFocus() const
94{
95 return gFocusMgr.getKeyboardFocus() == this;
96}
97
98void LLFocusableElement::setFocus(BOOL b)
99{
100}
101
102
41LLFocusMgr gFocusMgr; 103LLFocusMgr gFocusMgr;
42 104
43LLFocusMgr::LLFocusMgr() 105LLFocusMgr::LLFocusMgr()
@@ -87,11 +149,13 @@ void LLFocusMgr::releaseFocusIfNeeded( const LLView* view )
87} 149}
88 150
89 151
90void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock, BOOL keystrokes_only) 152void LLFocusMgr::setKeyboardFocus(LLFocusableElement* new_focus, BOOL lock, BOOL keystrokes_only)
91{ 153{
92 if (mLockedView && 154 if (mLockedView &&
93 (new_focus == NULL || 155 (new_focus == NULL ||
94 (new_focus != mLockedView && !new_focus->hasAncestor(mLockedView)))) 156 (new_focus != mLockedView
157 && dynamic_cast<LLView*>(new_focus)
158 && !dynamic_cast<LLView*>(new_focus)->hasAncestor(mLockedView))))
95 { 159 {
96 // don't allow focus to go to anything that is not the locked focus 160 // don't allow focus to go to anything that is not the locked focus
97 // or one of its descendants 161 // or one of its descendants
@@ -121,7 +185,8 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock, BOOL keystroke
121 mFocusTimer.reset(); 185 mFocusTimer.reset();
122 186
123 #ifdef _DEBUG 187 #ifdef _DEBUG
124 mKeyboardFocusName = new_focus ? new_focus->getName() : std::string("none"); 188 LLUICtrl* focus_ctrl = dynamic_cast<LLUICtrl*>(new_focus);
189 mKeyboardFocusName = focus_ctrl ? focus_ctrl->getName() : std::string("none");
125 #endif 190 #endif
126 191
127 // If we've got a default keyboard focus, and the caller is 192 // If we've got a default keyboard focus, and the caller is
@@ -131,8 +196,8 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock, BOOL keystroke
131 mDefaultKeyboardFocus->setFocus(TRUE); 196 mDefaultKeyboardFocus->setFocus(TRUE);
132 } 197 }
133 198
134 LLView* focus_subtree = mKeyboardFocus; 199 LLView* focus_subtree = dynamic_cast<LLView*>(mKeyboardFocus);
135 LLView* viewp = mKeyboardFocus; 200 LLView* viewp = dynamic_cast<LLView*>(mKeyboardFocus);
136 // find root-most focus root 201 // find root-most focus root
137 while(viewp) 202 while(viewp)
138 { 203 {
@@ -146,7 +211,8 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock, BOOL keystroke
146 211
147 if (focus_subtree) 212 if (focus_subtree)
148 { 213 {
149 mFocusHistory[focus_subtree->getHandle()] = mKeyboardFocus ? mKeyboardFocus->getHandle() : LLHandle<LLView>(); 214 LLView* focused_view = dynamic_cast<LLView*>(mKeyboardFocus);
215 mFocusHistory[focus_subtree->getHandle()] = focused_view ? focused_view->getHandle() : LLHandle<LLView>();
150 } 216 }
151 } 217 }
152 218
@@ -160,7 +226,7 @@ void LLFocusMgr::setKeyboardFocus(LLUICtrl* new_focus, BOOL lock, BOOL keystroke
160// Returns TRUE is parent or any descedent of parent has keyboard focus. 226// Returns TRUE is parent or any descedent of parent has keyboard focus.
161BOOL LLFocusMgr::childHasKeyboardFocus(const LLView* parent ) const 227BOOL LLFocusMgr::childHasKeyboardFocus(const LLView* parent ) const
162{ 228{
163 LLView* focus_view = mKeyboardFocus; 229 LLView* focus_view = dynamic_cast<LLView*>(mKeyboardFocus);
164 while( focus_view ) 230 while( focus_view )
165 { 231 {
166 if( focus_view == parent ) 232 if( focus_view == parent )
@@ -190,7 +256,7 @@ BOOL LLFocusMgr::childHasMouseCapture( const LLView* parent ) const
190 return FALSE; 256 return FALSE;
191} 257}
192 258
193void LLFocusMgr::removeKeyboardFocusWithoutCallback( const LLView* focus ) 259void LLFocusMgr::removeKeyboardFocusWithoutCallback( const LLFocusableElement* focus )
194{ 260{
195 // should be ok to unlock here, as you have to know the locked view 261 // should be ok to unlock here, as you have to know the locked view
196 // in order to unlock it 262 // in order to unlock it
@@ -313,7 +379,7 @@ void LLFocusMgr::removeTopCtrlWithoutCallback( const LLUICtrl* top_view )
313 379
314void LLFocusMgr::lockFocus() 380void LLFocusMgr::lockFocus()
315{ 381{
316 mLockedView = mKeyboardFocus; 382 mLockedView = dynamic_cast<LLUICtrl*>(mKeyboardFocus);
317} 383}
318 384
319void LLFocusMgr::unlockFocus() 385void LLFocusMgr::unlockFocus()