move charlist selection with arrows
This commit is contained in:
parent
c6b9aad87d
commit
6206eeb562
|
@ -26,6 +26,17 @@ local function createCharactersWindow(characters, premDays)
|
|||
local charactersList = charactersWindow:getChildById('charactersList')
|
||||
local accountStatusLabel = charactersWindow:getChildById('accountStatusLabel')
|
||||
|
||||
function charactersWindow:onKeyPress(keyCode, keyChar, keyboardModifiers)
|
||||
if keyboardModifiers == KeyboardNoModifier then
|
||||
if keyCode == KeyUp or keyCode == KeyTab then
|
||||
charactersList:focusPreviousChild(ActiveFocusReason)
|
||||
elseif keyCode == KeyDown then
|
||||
charactersList:focusNextChild(ActiveFocusReason)
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
for i,characterInfo in ipairs(characters) do
|
||||
local characterName = characterInfo[1]
|
||||
local worldName = characterInfo[2]
|
||||
|
|
|
@ -69,6 +69,8 @@ void LuaInterface::registerFunctions()
|
|||
g_lua.bindClassMemberFunction<UIWidget>("removeChild", &UIWidget::removeChild);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("addChild", &UIWidget::addChild);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("focusChild", &UIWidget::focusChild);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("focusNextChild", &UIWidget::focusNextChild);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("focusPreviousChild", &UIWidget::focusPreviousChild);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("lockChild", &UIWidget::lockChild);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("updateLayout", &UIWidget::updateLayout);
|
||||
g_lua.bindClassMemberFunction<UIWidget>("updateParentLayout", &UIWidget::updateParentLayout);
|
||||
|
|
|
@ -410,6 +410,32 @@ void UIWidget::focusNextChild(Fw::FocusReason reason)
|
|||
focusChild(toFocus, reason);
|
||||
}
|
||||
|
||||
void UIWidget::focusPreviousChild(Fw::FocusReason reason)
|
||||
{
|
||||
UIWidgetPtr toFocus;
|
||||
UIWidgetList rotatedChildren(m_children);
|
||||
std::reverse(m_children.begin(), m_children.end());
|
||||
|
||||
if(m_focusedChild) {
|
||||
auto focusedIt = std::find(rotatedChildren.begin(), rotatedChildren.end(), m_focusedChild);
|
||||
if(focusedIt != rotatedChildren.end()) {
|
||||
std::rotate(rotatedChildren.begin(), focusedIt, rotatedChildren.end());
|
||||
rotatedChildren.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
// finds next child to focus
|
||||
for(const UIWidgetPtr& child : rotatedChildren) {
|
||||
if(child->isFocusable()) {
|
||||
toFocus = child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(toFocus)
|
||||
focusChild(toFocus, reason);
|
||||
}
|
||||
|
||||
void UIWidget::moveChildToTop(const UIWidgetPtr& child)
|
||||
{
|
||||
if(!child)
|
||||
|
|
|
@ -128,6 +128,7 @@ public:
|
|||
void removeChild(const UIWidgetPtr& child);
|
||||
void focusChild(const UIWidgetPtr& child, Fw::FocusReason reason);
|
||||
void focusNextChild(Fw::FocusReason reason);
|
||||
void focusPreviousChild(Fw::FocusReason reason);
|
||||
void moveChildToTop(const UIWidgetPtr& child);
|
||||
void lockChild(const UIWidgetPtr& child);
|
||||
void unlockChild(const UIWidgetPtr& child);
|
||||
|
|
Loading…
Reference in New Issue