ruffle icon indicating copy to clipboard operation
ruffle copied to clipboard

core: Always fire `KeyPress` after `KeyDown` for buttons

Open kjarosh opened this issue 9 months ago • 0 comments

Just fixing a bug I found when writing some tests.

Button events are actually handled twofold:

  1. KeyPress for printable characters is handled on TextInput,
  2. KeyPress for special characters (e.g. enter, arrows) is handled on KeyDown.

Before this patch, KeyPress was fired too early, so that for special characters (2) it fired BEFORE KeyDown. This was not a problem for printable characters, as they fired on TextInput, which always fired separately after KeyDown.

This patch ensures that KeyPress is fired always in the proper order.

Additionally I added a test that verifies the "KeyPress events take precedence over text input" behavior, because it was not covered by tests before.

kjarosh avatar May 07 '24 22:05 kjarosh