picoe / Eto

Cross platform GUI framework for desktop and mobile applications in .NET
Other
3.52k stars 319 forks source link

TextArea text is not visible when using Wrap on macOS 14 #2617

Closed rodrigocmoreira closed 4 months ago

rodrigocmoreira commented 4 months ago

Expected Behavior

On macOS, the text in a TextArea is visible even when you have scrollbars and wrap is enabled.

Actual Behavior

On macOS, the text in a TextArea is not visible when using Wrap and your text has a vertical scrollbar, and if the text were not wrapped you would have a horizontal scrollbar.

Steps to Reproduce the Problem

  1. Open the Eto demo dialog on macOS 14.3 (Eto.Test.macOS)
  2. Open the TextArea control demo
  3. Add a lot of text that would cause a text wrap with horizontal and scrollbar
  4. Check the 'Wrap' checkbox
  5. You can continue checking and unchecking the Wrap checkbox and see that text will still not show in most cases.

Code that Demonstrates the Problem

The issue is in the code below, but I could not find any effective fix yet.

        public bool Wrap
        {
            get
            {
                return Control.TextContainer.WidthTracksTextView;
            }
            set
            {
                if (value)
                {
                    Control.TextContainer.WidthTracksTextView = true;
                    Control.NeedsLayout = true;
                }
                else
                {
                    Control.TextContainer.WidthTracksTextView = false;
                    Control.TextContainer.ContainerSize = new CGSize(float.MaxValue, float.MaxValue);
                }
            }
        }

Specifications

If you have a workaround I would be glad.

To solve this I am setting: handler.Control.HorizontallyResizable = false; When Wrap is true, don't seem to change anything visually, but then the issue is gone, but you might know some better solution.

rodrigocmoreira commented 4 months ago

This is the code I did on my end to fix the issue temporally

    static void FixTextAreaWrapping(TextAreaHandler handler)
    {
        // TODO: After upgrade to macOS 14, text in the multiline textboxes with wrapping became invisible.
        // To workaround the issue we can reset the wrapping after the control is shown.
        // Need to check if the issue is still actual in the next macos releases,
        // otherwise we can remove this workaround.
        if (handler.Wrap)
        {
            // There is a bug on Eto and is reproducible in the test app from Eto.
            // If a resize happens while wrap is false then the text will not be visible
            // with this solution we quickly change this and prevent this issue of happening
            handler.Control.HorizontalContentSizeConstraintActive = false;
            handler.Control.HorizontallyResizable = false;
            handler.Wrap = false;
            handler.Widget.Shown += OnShown;

            void OnShown(object sender, EventArgs e)
            {
                handler.Widget.Shown -= OnShown;
                handler.Wrap = true;
            }
        }
    }
rodrigocmoreira commented 4 months ago

Just to add that this fix only works if the project is build in a machine with Xcode 15+

cwensley commented 4 months ago

Yep, definitely an issue. Thanks for reporting it!