You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2013/10/11 08:15:03 UTC
[08/13] git commit: [flex-sdk] [refs/heads/develop] - FLEX-33772
Incorrect tab focus behaviour
FLEX-33772 Incorrect tab focus behaviour
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/edb146e5
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/edb146e5
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/edb146e5
Branch: refs/heads/develop
Commit: edb146e5aac2fe6db826925fd680e82dad6132f4
Parents: 8eddfd0
Author: Justin Mclean <jm...@apache.org>
Authored: Fri Oct 11 10:16:36 2013 +1100
Committer: Justin Mclean <jm...@apache.org>
Committed: Fri Oct 11 10:16:36 2013 +1100
----------------------------------------------------------------------
.../framework/src/mx/managers/FocusManager.as | 95 ++++++++++++++++----
1 file changed, 79 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/edb146e5/frameworks/projects/framework/src/mx/managers/FocusManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/src/mx/managers/FocusManager.as b/frameworks/projects/framework/src/mx/managers/FocusManager.as
index 4af19fd..6f17a07 100644
--- a/frameworks/projects/framework/src/mx/managers/FocusManager.as
+++ b/frameworks/projects/framework/src/mx/managers/FocusManager.as
@@ -1379,29 +1379,92 @@ public class FocusManager extends EventDispatcher implements IFocusManager
var o:DisplayObject = DisplayObject(findFocusManagerComponent2(focusableCandidates[i]));
if (o is IFocusManagerGroup)
{
- // look around to see if there's an enabled and visible
- // selected member in the tabgroup, otherwise use the first
- // one we found.
+
+ // when landing on an element that is part of group, try to
+ // advance selection to the selected group element
+ var j:int;
+ var obj:DisplayObject;
var tg1:IFocusManagerGroup = IFocusManagerGroup(o);
- for (var j:int = 0; j < focusableCandidates.length; j++)
+ var tg2:IFocusManagerGroup;
+
+ // normalize the "no selected group element" case
+ // to the "first group element selected" case
+ // (respecting the tab direction)
+ var groupElementToFocus:IFocusManagerGroup = null;
+ for (j = 0; j < focusableCandidates.length; j++)
{
- var obj:DisplayObject = focusableCandidates[j];
- if (obj is IFocusManagerGroup && isEnabledAndVisible(obj))
+ obj = focusableCandidates[j];
+ if (obj is IFocusManagerGroup)
{
- var tg2:IFocusManagerGroup = IFocusManagerGroup(obj);
- if (tg2.groupName == tg1.groupName && tg2.selected)
+ tg2 = IFocusManagerGroup(obj);
+ if (tg2.groupName == tg1.groupName && isEnabledAndVisible(obj))
{
- // if objects of same group have different tab index
- // skip you aren't selected.
- if (InteractiveObject(obj).tabIndex != InteractiveObject(o).tabIndex && !tg1.selected)
- return getIndexOfNextObject(i, shiftKey, bSearchAll, groupName);
-
- i = j;
- break;
+ if (tg2.selected)
+ {
+ groupElementToFocus = tg2;
+ break;
+ }
+ if ((!shiftKey && groupElementToFocus == null) || shiftKey)
+ groupElementToFocus = tg2;
+ }
+ }
+ }
+
+ if (tg1 != groupElementToFocus)
+ {
+ // cycle the entire focusable candidates array forward or backward,
+ // wrapping around boundaries, searching for our focus candidate
+ j = i;
+ for (var k:int = 0; k < focusableCandidates.length - 1; k++)
+ {
+
+ if (!shiftKey)
+ {
+ j++;
+ if (j == focusableCandidates.length)
+ j = 0;
+ }
+ else
+ {
+ j--;
+ if (j == -1)
+ j = focusableCandidates.length - 1;
+ }
+
+ obj = focusableCandidates[j];
+ if (isEnabledAndVisible(obj))
+ {
+ if (obj is IFocusManagerGroup)
+ {
+ tg2 = IFocusManagerGroup(obj);
+ if (tg2.groupName == tg1.groupName)
+ {
+ if (tg2 == groupElementToFocus)
+ {
+ // if objects of same group have different tab index
+ // skip you aren't selected.
+ if (InteractiveObject(obj).tabIndex != InteractiveObject(o).tabIndex && !tg1.selected)
+ return getIndexOfNextObject(i, shiftKey, bSearchAll, groupName);
+ i = j;
+ break;
+ }
+ }
+ else
+ {
+ // element is part of another group, stop (no recursive search)
+ i = j;
+ break;
+ }
+ }
+ else
+ {
+ // element isn't part of any group, stop
+ i = j;
+ break;
+ }
}
}
}
-
}
return i;
}