| 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 | { |
no test coverage detected