MCPcopy Create free account
hub / github.com/MyGUI/mygui / setKeyFocusWidget

Method setKeyFocusWidget

MyGUIEngine/src/MyGUI_InputManager.cpp:388–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

386 }
387
388 void InputManager::setKeyFocusWidget(Widget* _widget)
389 {
390 if (_widget == mWidgetKeyFocus)
391 return;
392
393 Widget* oldKeyFocus = mWidgetKeyFocus;
394 mWidgetKeyFocus = nullptr;
395
396 Widget* sharedRootFocus = nullptr; // possible shared parent for both old and new widget
397
398 // recursively set root key focus
399 Widget* rootFocus = _widget;
400 while (rootFocus != nullptr)
401 {
402 if (rootFocus->getRootKeyFocus())
403 {
404 sharedRootFocus = rootFocus;
405 break;
406 }
407
408 rootFocus->_setRootKeyFocus(true);
409 rootFocus->_riseKeyChangeRootFocus(true);
410 rootFocus = rootFocus->getParent();
411 }
412
413 // recursively reset root key focus
414 rootFocus = oldKeyFocus;
415 while (rootFocus != nullptr)
416 {
417 if (rootFocus == sharedRootFocus)
418 break;
419
420 rootFocus->_setRootKeyFocus(false);
421 rootFocus->_riseKeyChangeRootFocus(false);
422 rootFocus = rootFocus->getParent();
423 }
424 //-------------------------------------------------------------------------------------//
425
426 mWidgetKeyFocus = _widget;
427
428 if (oldKeyFocus)
429 {
430 oldKeyFocus->_riseKeyLostFocus(_widget);
431 }
432
433 if (_widget)
434 {
435 _widget->_riseKeySetFocus(mWidgetKeyFocus);
436 }
437
438 eventChangeKeyFocus(mWidgetKeyFocus);
439 }
440
441 void InputManager::_resetMouseFocusWidget()
442 {

Callers 12

InputManager.hFile · 0.80
onKeyButtonPressedMethod · 0.80
notifyMenuCtrlAcceptMethod · 0.80
notifyMouseSetFocusMethod · 0.80
setVisibleMethod · 0.80
showListMethod · 0.80
onDoModalMethod · 0.80

Calls 6

getRootKeyFocusMethod · 0.80
_setRootKeyFocusMethod · 0.80
_riseKeyLostFocusMethod · 0.80
_riseKeySetFocusMethod · 0.80
getParentMethod · 0.45

Tested by

no test coverage detected