Game Development Reference
In-Depth Information
control)
{
if (control == nullptr ||
control->GetCanFocus())
{
_focusControl = control;
return true;
}
else
return false;
}
void Menu::NextFocus()
{
if (_focusControl == nullptr)
_focusControl = _controls.at(0);
else
{
auto it = _controls.begin();
for (; it != _controls.end(); ++it)
{
if (*it == _focusControl)
{
++it;
break;
}
}
if (it != _controls.end())
_focusControl = *it;
else
_focusControl = nullptr;
}
}
SetFocus() allows us to explicitly set a particular control as the focused control,
while NextFocus() iterates through the control list until it finds the currently fo-
cused control, and then proceeds through the list until it finds another control that
can be focused on. This new control becomes the focused control at this point.
Search WWH ::




Custom Search