airsdk / Adobe-Runtime-Support

Report, track and discuss issues in Adobe AIR. Monitored by Adobe - and HARMAN - and maintained by the AIR community.
201 stars 11 forks source link

[AIR 51] Incorrect text selection when select text to left/right side of the text field #3311

Closed ylazy closed 2 months ago

ylazy commented 3 months ago

Please see the clip below for more information (the issue does not happen in Air 32, happen in Air 51)

https://github.com/airsdk/Adobe-Runtime-Support/assets/6010183/dfb66f0d-788a-488d-97c3-7d969d71e469

When I clicked on the middle of the line (hold the mouse) then moved to the left/right. When the mouse fall outside of the text field, the selection was incorrect and blink.

In the video I've tested with the left side only. In fact the issue happens with the right side too.

Thanks!

ylazy commented 3 months ago

I added the code below to easily reproduce the problem:

FontManager.embed(Arial); // embed the Arial font

var format:TextFormat = new TextFormat();
format.font = "Arial";

var tf:TextField = new TextField();
tf.defaultTextFormat = format;
tf.border = true;
tf.width = 300;
tf.height = 200;
tf.wordWrap = false;
tf.multiline = true;
tf.type = TextFieldType.DYNAMIC;
tf.selectable = true;
tf.embedFonts = true;
tf.text = "first line\nsecond line\nthird line";
addChild(tf);

https://github.com/airsdk/Adobe-Runtime-Support/assets/6010183/08e7db99-87ae-4cdb-b134-3455372b0729

The issue only happens with embed fonts. Click on any position in the middle of the second line, then move to the left/right until the mouse fall outside the text field, you can see the selection will be blinked and incorrect.

ajwfrost commented 3 months ago

Thanks So the key factors were the embedded fonts and the lack of word wrap. With embedded fonts, there are some re-calculations done to the mouse event so that it can be translated into a row/column position. But then when we're out of the area, we trigger the auto-scroll functionality (assuming word wrap is off) and this is where it was going wrong .. the translated point was being fed back into the handler to work out where to extend the selection to, but the mouse translation was then being applied again -> suddenly it thought the mouse was way off to the bottom left somewhere... Should be a generic fix for this kind of situation. thanks

ylazy commented 2 months ago

Fixed on AIR SDK 51.0.1.4.

Thanks!