-
-
Notifications
You must be signed in to change notification settings - Fork 843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avm2: Use Line Feed character for textInput newline events #19517
Draft
evilpie
wants to merge
2
commits into
ruffle-rs:master
Choose a base branch
from
evilpie:textfield-newline
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,40 @@ | ||
package { | ||
import flash.display.Sprite; | ||
import flash.events.Event; | ||
import flash.events.KeyboardEvent; | ||
import flash.events.TextEvent; | ||
import flash.text.TextField; | ||
import flash.text.TextFieldType; | ||
|
||
public class Test extends Sprite { | ||
public function Test() { | ||
var textField: TextField = new TextField(); | ||
textField.type = TextFieldType.INPUT; | ||
textField.border = true; | ||
textField.multiline = true; | ||
textField.height = 200; | ||
textField.addEventListener(Event.CHANGE, onChange); | ||
textField.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); | ||
textField.addEventListener(TextEvent.TEXT_INPUT, onTextInput); | ||
addChild(textField); | ||
} | ||
|
||
public function onChange(evt: Event): void { | ||
trace("onChange"); | ||
|
||
var text: String = evt.target.text; | ||
for (var i: int = 0; i < text.length; i++) { | ||
trace(" U+" + text.charCodeAt(i).toString(16)); | ||
} | ||
} | ||
|
||
public function onKeyDown(evt: KeyboardEvent): void { | ||
// TODO: We must not be firing this event yet. | ||
// trace("onKeyDown: U+" + evt.charCode.toString(16)); | ||
} | ||
|
||
public function onTextInput(evt: TextEvent): void { | ||
trace("onTextInput: U+" + evt.text.charCodeAt(0).toString(16)); | ||
} | ||
} | ||
} |
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,7 @@ | ||
[ | ||
{ "type": "MouseDown", "pos": [10, 10], "btn": "Left" }, | ||
{ "type": "TextInput", "codepoint": "a" }, | ||
{ "type": "TextControl", "code": "Enter" }, | ||
{ "type": "TextInput", "codepoint": "b" }, | ||
{ "type": "TextControl", "code": "Enter" } | ||
] |
18 changes: 18 additions & 0 deletions
18
tests/tests/swfs/avm2/edittext_newline_character/output.txt
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,18 @@ | ||
onTextInput: U+61 | ||
onChange | ||
U+61 | ||
onTextInput: U+a | ||
onChange | ||
U+61 | ||
U+d | ||
onTextInput: U+62 | ||
onChange | ||
U+61 | ||
U+d | ||
U+62 | ||
onTextInput: U+a | ||
onChange | ||
U+61 | ||
U+d | ||
U+62 | ||
U+d |
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this comment mean? Why can't you just fire the event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry, I misunderstood the comment. I thought we cannot fire the event here somehow.
The key down/up events are separate from text input events, you need to add them to
input.json
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we not have a way of producing the TEXT_INPUT and KEY_DOWN event with just one line in
input.json
? It seems a bit pointless to test if both results are basically hardcoded. (We also don't seem to support specifying a character for test KeyDown events, which is another problem)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope
Text input is inherently different from key up/down, because it goes through the OS (keyboard layout, mapping, etc.). We cannot infer one from the other, it's done outside of Ruffle.
I agree, I remember adding key char as an optional field in the automated event. Maybe I'll find the commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I remember now. I worked on redoing key events in Ruffle to properly support key mapping. I believe we should do it first, because key code can be inferred from key char (
contrary to text inputor maybe, when we have key char, I'm actually not sure).TL;DR we need to refactor input a bit