43 mWidgetMouseFocus = 0;
46 mIsWidgetMouseCapture =
false;
47 mIsShiftPressed =
false;
48 mIsControlPressed =
false;
51 mFirstPressKey =
true;
64 if (!mIsInitialise)
return;
71 mIsInitialise =
false;
77 mMousePosition.
set(_absx, _absy);
80 int relz = _absz - mOldAbsZ;
87 if (mWidgetMouseFocus !=
nullptr) mWidgetMouseFocus->
onMouseWheel(relz);
91 if (mIsWidgetMouseCapture)
93 if (mWidgetMouseFocus !=
nullptr)
95 if (mLayerMouseFocus !=
nullptr)
102 mIsWidgetMouseCapture =
false;
106 Widget* old_mouse_focus = mWidgetMouseFocus;
112 if (mWidgetMouseFocus == item)
115 if (mWidgetMouseFocus !=
nullptr)
117 if (mLayerMouseFocus !=
nullptr)
133 if (!mVectorModalRootWidget.empty())
135 if (root != mVectorModalRootWidget.back())
143 mLayerMouseFocus = root->
getLayer();
153 Widget* save_widget =
nullptr;
156 Widget* root_focus = item;
157 while (root_focus !=
nullptr)
159 if (root_focus->mRootMouseActive)
161 save_widget = root_focus;
164 root_focus->mRootMouseActive =
true;
176 root_focus = mWidgetMouseFocus;
177 while (root_focus !=
nullptr)
179 if (root_focus == save_widget)
183 root_focus->mRootMouseActive =
false;
196 if ((mWidgetMouseFocus !=
nullptr) && (mWidgetMouseFocus->
isEnabled()))
204 if ((item !=
nullptr) && (item->
isEnabled()))
211 mWidgetMouseFocus = item;
213 if (old_mouse_focus != mWidgetMouseFocus)
221 Widget* old_key_focus = mWidgetKeyFocus;
228 if (old_key_focus != mWidgetKeyFocus)
243 mIsWidgetMouseCapture =
true;
245 if (mLayerMouseFocus !=
nullptr)
248 mLastLeftPressed = point;
253 Widget* item = mWidgetMouseFocus;
260 if (mWidgetMouseFocus !=
nullptr)
265 if (mWidgetMouseFocus)
271 Widget* pick = mWidgetMouseFocus;
286 if (old_key_focus != mWidgetKeyFocus)
302 if (mIsWidgetMouseCapture)
305 mIsWidgetMouseCapture =
false;
308 if (
nullptr != mWidgetMouseFocus)
320 if ( item == mWidgetMouseFocus)
341 firstEncoding(_key,
true);
344 storeKey(_key, _text);
360 firstEncoding(_key,
false);
372 void InputManager::firstEncoding(
KeyCode _key,
bool bIsKeyPressed)
375 mIsShiftPressed = bIsKeyPressed;
377 mIsControlPressed = bIsKeyPressed;
382 if (_widget == mWidgetKeyFocus)
387 Widget* save_widget =
nullptr;
390 Widget* root_focus = _widget;
391 while (root_focus !=
nullptr)
393 if (root_focus->mRootKeyActive)
395 save_widget = root_focus;
398 root_focus->mRootKeyActive =
true;
410 root_focus = mWidgetKeyFocus;
411 while (root_focus !=
nullptr)
413 if (root_focus == save_widget)
417 root_focus->mRootKeyActive =
false;
441 mWidgetKeyFocus = _widget;
447 Widget* root_focus = mWidgetMouseFocus;
448 while (root_focus !=
nullptr)
450 root_focus->mRootMouseActive =
false;
461 mIsWidgetMouseCapture =
false;
462 if (
nullptr != mWidgetMouseFocus)
465 mWidgetMouseFocus =
nullptr;
471 void InputManager::_unlinkWidget(
Widget* _widget)
473 if (
nullptr == _widget)
return;
474 if (_widget == mWidgetMouseFocus)
476 mIsWidgetMouseCapture =
false;
477 mWidgetMouseFocus =
nullptr;
479 if (_widget == mWidgetKeyFocus)
481 mWidgetKeyFocus =
nullptr;
485 for (VectorWidgetPtr::iterator iter=mVectorModalRootWidget.begin(); iter!=mVectorModalRootWidget.end(); ++iter)
487 if ((*iter == _widget))
489 mVectorModalRootWidget.erase(iter);
498 if (
nullptr == _widget)
return;
503 mVectorModalRootWidget.push_back(_widget);
514 for (VectorWidgetPtr::iterator iter=mVectorModalRootWidget.begin(); iter!=mVectorModalRootWidget.end(); ++iter)
516 if ((*iter == _widget))
518 mVectorModalRootWidget.erase(iter);
523 if (!mVectorModalRootWidget.empty())
530 void InputManager::storeKey(
KeyCode _key,
Char _text)
541 mFirstPressKey =
true;
547 void InputManager::resetKey()
553 void InputManager::frameEntered(
float _frame)
571 mFirstPressKey =
false;
590 if (mWidgetKeyFocus == _widget)
596 if (mLayerMouseFocus !=
nullptr)
598 return mMousePosition;