-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathFocusUtil.hx
More file actions
74 lines (68 loc) · 2.11 KB
/
FocusUtil.hx
File metadata and controls
74 lines (68 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
Feathers UI
Copyright 2026 Bowler Hat LLC. All Rights Reserved.
This program is free software. You can redistribute and/or modify it in
accordance with the terms of the accompanying license agreement.
*/
package feathers.utils;
import feathers.core.IFocusContainer;
import feathers.core.IFocusExtras;
import feathers.core.IFocusObject;
import openfl.display.DisplayObject;
import openfl.display.DisplayObjectContainer;
import openfl.errors.ArgumentError;
import openfl.geom.Point;
/**
Focus utility functions.
@see `feathers.core.FocusManager`
@since 1.0.0
**/
class FocusUtil {
public static function findAllFocusableObjects(target:DisplayObject, ?result:Array<IFocusObject>):Array<IFocusObject> {
if (result == null) {
result = [];
}
if ((target is IFocusObject)) {
var focusableObject:IFocusObject = cast target;
if (focusableObject.focusEnabled) {
result.push(focusableObject);
}
}
if ((target is IFocusExtras)) {
var focusExtras:IFocusExtras = cast target;
var extras = focusExtras.focusExtrasBefore;
if (extras != null) {
for (i in 0...extras.length) {
var childOfTarget = extras[i];
findAllFocusableObjects(childOfTarget, result);
}
}
}
if ((target is IFocusObject)) {
if ((target is IFocusContainer) && (cast target : IFocusContainer).childFocusEnabled) {
var otherContainer = cast(target, DisplayObjectContainer);
for (i in 0...otherContainer.numChildren) {
var childOfTarget = otherContainer.getChildAt(i);
findAllFocusableObjects(childOfTarget, result);
}
}
} else if ((target is DisplayObjectContainer)) {
var otherContainer:DisplayObjectContainer = cast target;
for (i in 0...otherContainer.numChildren) {
var childOfTarget = otherContainer.getChildAt(i);
findAllFocusableObjects(childOfTarget, result);
}
}
if ((target is IFocusExtras)) {
var focusExtras:IFocusExtras = cast target;
var extras = focusExtras.focusExtrasAfter;
if (extras != null) {
for (i in 0...extras.length) {
var childOfTarget = extras[i];
findAllFocusableObjects(childOfTarget, result);
}
}
}
return result;
}
}