-
-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Add focus_keyboard_press test
This test verifies the behavior of pressing buttons with a keyboard.
- Loading branch information
Showing
5 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
[ | ||
{ "type": "KeyDown", "key_code": 9 }, { "type": "TextInput", "codepoint": "\t" }, { "type": "KeyUp", "key_code": 9 }, | ||
{ "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, | ||
{ "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, | ||
{ "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, | ||
{ "type": "MouseMove", "pos": [5, 5] }, | ||
{ "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, | ||
{ "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, | ||
{ "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, | ||
|
||
{ "type": "KeyDown", "key_code": 9 }, { "type": "TextInput", "codepoint": "\t" }, { "type": "KeyUp", "key_code": 9 }, | ||
|
||
{ "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, | ||
{ "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, | ||
{ "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, | ||
{ "type": "MouseMove", "pos": [5, 5] }, | ||
{ "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, | ||
{ "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, | ||
{ "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, | ||
|
||
{ "type": "KeyDown", "key_code": 9 }, { "type": "TextInput", "codepoint": "\t" }, { "type": "KeyUp", "key_code": 9 }, | ||
|
||
{ "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, | ||
{ "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, | ||
{ "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, | ||
{ "type": "MouseMove", "pos": [5, 5] }, | ||
{ "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, | ||
{ "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, | ||
{ "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, | ||
|
||
{ "type": "KeyDown", "key_code": 27 }, { "type": "KeyUp", "key_code": 27 }, | ||
|
||
{ "type": "KeyDown", "key_code": 9 }, { "type": "TextInput", "codepoint": "\t" }, { "type": "KeyUp", "key_code": 9 }, | ||
{ "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, | ||
{ "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, | ||
{ "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, | ||
{ "type": "MouseMove", "pos": [5, 5] }, | ||
{ "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, | ||
{ "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, | ||
{ "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, | ||
|
||
{ "type": "KeyDown", "key_code": 9 }, { "type": "TextInput", "codepoint": "\t" }, { "type": "KeyUp", "key_code": 9 }, | ||
|
||
{ "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, | ||
{ "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, | ||
{ "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, | ||
{ "type": "MouseMove", "pos": [5, 5] }, | ||
{ "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, | ||
{ "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, | ||
{ "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, | ||
|
||
{ "type": "KeyDown", "key_code": 9 }, { "type": "TextInput", "codepoint": "\t" }, { "type": "KeyUp", "key_code": 9 }, | ||
|
||
{ "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, | ||
{ "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, | ||
{ "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 }, | ||
{ "type": "MouseMove", "pos": [5, 5] }, | ||
{ "type": "KeyDown", "key_code": 13 }, { "type": "TextInput", "codepoint": "\n" }, { "type": "KeyUp", "key_code": 13 }, | ||
{ "type": "KeyDown", "key_code": 32 }, { "type": "TextInput", "codepoint": " " }, { "type": "KeyUp", "key_code": 32 }, | ||
{ "type": "KeyDown", "key_code": 65 }, { "type": "TextInput", "codepoint": "a" }, { "type": "KeyUp", "key_code": 65 } | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
Focus at: _level0.text | ||
Tab pressed | ||
Focus at: _level0.clip | ||
_level0.clip.onKeyUp: 9 | ||
_level0.clip.onKeyDown: 13 | ||
_level0.clip.onPress: 13 | ||
_level0.clip.onRelease: 13 | ||
_level0.clip.onKeyUp: 13 | ||
_level0.clip.onKeyDown: 32 | ||
_level0.clip.onPress: 32 | ||
_level0.clip.onRelease: 32 | ||
_level0.clip.onKeyUp: 32 | ||
_level0.clip.onKeyDown: 65 | ||
_level0.clip.onKeyUp: 65 | ||
_level0.clip.onMouseMove | ||
Tab pressed | ||
Focus at: _level0.button | ||
_level0.button.onKeyUp: 9 | ||
_level0.button.onKeyDown: 13 | ||
press | ||
_level0.button.onPress: 13 | ||
release | ||
_level0.button.onRelease: 13 | ||
_level0.button.onKeyUp: 13 | ||
_level0.button.onKeyDown: 32 | ||
press | ||
_level0.button.onPress: 32 | ||
release | ||
_level0.button.onRelease: 32 | ||
_level0.button.onKeyUp: 32 | ||
_level0.button.onKeyDown: 65 | ||
_level0.button.onKeyUp: 65 | ||
_level0.clip.onMouseMove | ||
Tab pressed | ||
Focus at: _level0.text | ||
_level0.clip.onMouseMove | ||
Escape pressed | ||
Tab pressed | ||
Focus at: _level0.clip | ||
_level0.clip.onKeyUp: 9 | ||
_level0.clip.onKeyDown: 13 | ||
_level0.clip.onKeyUp: 13 | ||
_level0.clip.onKeyDown: 32 | ||
_level0.clip.onKeyUp: 32 | ||
_level0.clip.onKeyDown: 65 | ||
_level0.clip.onKeyUp: 65 | ||
_level0.clip.onMouseMove | ||
Tab pressed | ||
Focus at: _level0.button | ||
_level0.button.onKeyUp: 9 | ||
_level0.button.onKeyDown: 13 | ||
_level0.button.onKeyUp: 13 | ||
_level0.button.onKeyDown: 32 | ||
_level0.button.onKeyUp: 32 | ||
_level0.button.onKeyDown: 65 | ||
_level0.button.onKeyUp: 65 | ||
_level0.clip.onMouseMove | ||
Tab pressed | ||
Focus at: _level0.text | ||
_level0.clip.onMouseMove |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var listener = new Object(); | ||
listener.onSetFocus = function(oldFocus, newFocus) { | ||
trace("Focus at: " + newFocus); | ||
}; | ||
listener.onKeyDown = function() { | ||
if (Key.getCode() == 27) { | ||
trace("Escape pressed"); | ||
_focusrect = false; | ||
Selection.setFocus(text); | ||
} | ||
if (Key.getCode() == 9) { | ||
trace("Tab pressed"); | ||
} | ||
}; | ||
Selection.addListener(listener); | ||
Key.addListener(listener); | ||
|
||
function setHandlers(obj) { | ||
obj.onRelease = function () { trace(obj + ".onRelease: " + Key.getCode()); } | ||
obj.onKeyDown = function () { trace(obj + ".onKeyDown: " + Key.getCode()); } | ||
obj.onKeyUp = function () { trace(obj + ".onKeyUp: " + Key.getCode()); } | ||
obj.onPress = function () { trace(obj + ".onPress: " + Key.getCode()); } | ||
obj.onReleaseOutside = function () { trace(obj + ".onReleaseOutside"); } | ||
obj.onMouseDown = function () { trace(obj + ".onMouseDown") } | ||
obj.onMouseUp = function () { trace(obj + ".onMouseUp") } | ||
obj.onMouseMove = function () { trace(obj + ".onMouseMove") } | ||
} | ||
|
||
clip.tabEnabled = true; | ||
clip.tabIndex = 1; | ||
setHandlers(clip); | ||
button.tabEnabled = true; | ||
button.tabIndex = 2; | ||
setHandlers(button); | ||
text.tabEnabled = true; | ||
text.tabIndex = 3; | ||
setHandlers(text); | ||
|
||
Selection.setFocus(text); |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
num_ticks = 1 |