airsdk / Adobe-Runtime-Support

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

flash.text.Textfield selected scrolls down, last line doesn't displayed in some case #3264

Open pol2095 opened 1 month ago

pol2095 commented 1 month ago

Problem Description

when I select the text and move the mouse down, the last line is selected but not visible (flash.text.Textfield doesn't scroll to see the last line) if the mouse is positioned on the right of the textfield.

Steps to Reproduce

when I select the text and move the mouse down, the last line is selected but not visible (flash.text.Textfield doesn't scroll to see the last line) if the mouse is positioned on the right of the textfield.

package
{
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.text.TextField;

    public class Main extends Sprite
    {
        public function Main()
        {
            this.addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
        }

        private function addedToStageHandler(e:Event):void
        {
            this.removeEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;

            var textField:TextField = new TextField();
            textField.background = true;
            textField.border = true;
            textField.type = "input";
            textField.wordWrap = true;
            textField.multiline = true;
            textField.y = 40;
            textField.width = 300;

            textField.text = "ActionScript provides several ways to format your text at runtime. The TextFormat class lets you set character and paragraph formatting for TextField objects. You can apply Cascading Style Sheets (CSS) styles to text fields by using the TextField.styleSheet property and the StyleSheet class. You can use CSS to style built-in HTML tags, define new formatting tags, or apply styles. You can assign HTML formatted text, which optionally uses CSS styles, directly to a text field. HTML text that you assign to a text field can contain embedded media (movie clips, SWF files, GIF files, PNG files, and JPEG files).";
            this.addChild(textField);
        }
    }
}

Actual result : Sans titre

Expected result : Sans titre2

Known Workarounds

No workaround

ylazy commented 1 month ago

I can't reproduce your problem on my machine (Windows 11, AIR 32/51), the text is displayed fully including the last sentence:

image

if the mouse is positioned on the right of the textfield.

I don't understand this. I think you should make a screen record to show your actions.

ajwfrost commented 1 month ago

It depends a bit how the text is wrapped. If you add a few more words so that the final sentence only goes a little in to the line, but the mouse is to the right of this, then it won't display the final line. But if you move your mouse to the left so that it's vertically underneath where the full stop should be, then the final scroll happens.

Seems to be related to the fact that the selections don't actually go to the end of the line (or the start, if you're moving your mouse above the text field), although this particular behaviour does then match notepad (and HTML/Edge, just looking at this editor itself...)

But a fairly easy fix, there are some conditions about the scroll amount vs selection position, but ultimately if you're dragging downwards on a text field, it should always scroll.

FYI we also found that the auto-scroll doesn't properly select the text if you hold the mouse still. So e.g. start a selection at the top of the text field, quickly move your mouse down to below the text field and then stop it moving, the text field should scroll down line by line with the selection expanding to match... but although the scrolling works, the selection doesn't.

Interesting, these problems seem to have been in the TextField control for many many years..?!

thanks

pol2095 commented 1 month ago

I tried spark.components.TextArea using TLF, it doesn't have this behaviors, but mx.controls.TextArea using flash.text.TextField have the same behaviors.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    addedToStage="ats(event)">

    <fx:Script>
        <![CDATA[
            private function ats(event:Event):void
            {
                tlfTextField.text = "ActionScript provides several ways to format your text at runtime. The TextFormat class lets you set character and paragraph formatting for TextField objects. You can apply Cascading Style Sheets (CSS) styles to text fields by using the TextField.styleSheet property and the StyleSheet class. You can use CSS to style built-in HTML tags, define new formatting tags, or apply styles. You can assign HTML formatted text, which optionally uses CSS styles, directly to a text field. HTML text that you assign to a text field can contain embedded media (movie clips, SWF files, GIF files, PNG files, and JPEG files).";

                textField.text = "ActionScript provides several ways to format your text at runtime. The TextFormat class lets you set character and paragraph formatting for TextField objects. You can apply Cascading Style Sheets (CSS) styles to text fields by using the TextField.styleSheet property and the StyleSheet class. You can use CSS to style built-in HTML tags, define new formatting tags, or apply styles. You can assign HTML formatted text, which optionally uses CSS styles, directly to a text field. HTML text that you assign to a text field can contain embedded media (movie clips, SWF files, GIF files, PNG files, and JPEG files).";
            }
        ]]>
    </fx:Script>

    <s:VGroup>
        <s:TextArea width="300" height="150" id="tlfTextField"/>
        <mx:TextArea width="300" height="150" id="textField"/>
    </s:VGroup>
</s:Application>