fix moving focus out of disabled focused widget - close #262

This commit is contained in:
Vadim Lopatin 2016-05-18 11:21:48 +03:00
parent 977bfd5270
commit e7e32db3be
1 changed files with 6 additions and 6 deletions

View File

@ -854,7 +854,7 @@ public:
} }
} }
private void findFocusableChildren(ref TabOrderInfo[] results, Rect clipRect) { private void findFocusableChildren(ref TabOrderInfo[] results, Rect clipRect, Widget currentWidget) {
if (visibility != Visibility.Visible) if (visibility != Visibility.Visible)
return; return;
Rect rc = _pos; Rect rc = _pos;
@ -862,23 +862,23 @@ public:
applyPadding(rc); applyPadding(rc);
if (!rc.intersects(clipRect)) if (!rc.intersects(clipRect))
return; // out of clip rectangle return; // out of clip rectangle
if (canFocus) { if (canFocus || this is currentWidget) {
TabOrderInfo item = new TabOrderInfo(this, rc); TabOrderInfo item = new TabOrderInfo(this, rc);
results ~= item; results ~= item;
return; return;
} }
rc.intersect(clipRect); rc.intersect(clipRect);
for (int i = 0; i < childCount(); i++) { for (int i = 0; i < childCount(); i++) {
child(i).findFocusableChildren(results, rc); child(i).findFocusableChildren(results, rc, currentWidget);
} }
} }
/// find all focusables belonging to the same focusGroup as this widget (does not include current widget). /// find all focusables belonging to the same focusGroup as this widget (does not include current widget).
/// usually to be called for focused widget to get possible alternatives to navigate to /// usually to be called for focused widget to get possible alternatives to navigate to
private TabOrderInfo[] findFocusables() { private TabOrderInfo[] findFocusables(Widget currentWidget) {
TabOrderInfo[] result; TabOrderInfo[] result;
Widget group = focusGroupWidget(); Widget group = focusGroupWidget();
group.findFocusableChildren(result, group.pos); group.findFocusableChildren(result, group.pos, currentWidget);
for (ushort i = 0; i < result.length; i++) for (ushort i = 0; i < result.length; i++)
result[i].childOrder = i + 1; result[i].childOrder = i + 1;
sort(result); sort(result);
@ -901,7 +901,7 @@ public:
private Widget findNextFocusWidget(FocusMovement direction) { private Widget findNextFocusWidget(FocusMovement direction) {
if (direction == FocusMovement.None) if (direction == FocusMovement.None)
return this; return this;
TabOrderInfo[] focusables = findFocusables(); TabOrderInfo[] focusables = findFocusables(this);
if (!focusables.length) if (!focusables.length)
return null; return null;
int myIndex = -1; int myIndex = -1;