Skip to content
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

[BUG] DocumentPage content loses focus if property changed #2606

Open
marcoburato opened this issue Jan 6, 2024 · 0 comments
Open

[BUG] DocumentPage content loses focus if property changed #2606

marcoburato opened this issue Jan 6, 2024 · 0 comments

Comments

@marcoburato
Copy link

Expected Behavior

Changing DocumentPage.Text on the active page causes its content to lose focus.

Actual Behavior

Changing DocumentPage.Text should not alter the focused component.

Steps to Reproduce the Problem

In the supplied code:

  1. Click on the textbox to focus it
  2. Start typing
  3. Observe how the TextBox.TextChanged handler adds a * to DocumentPage.Text and now the textbox is no longer focused.

I believe this happens because ThemedDocumentControlHandler.SetPageContent() always sets Content to null before setting it to something else.

In my actual code I'm using a custom Drawable and I noticed that OnLostFocus() does not get called, but OnUnLoad() is.

Code that Demonstrates the Problem

using System;
using Eto.Drawing;
using Eto.Forms;

namespace DocumentControlTest
{
    public class MainForm : Form
    {
        private DocumentPage _page;

        public MainForm()
        {
            Title = "My Eto Form";
            MinimumSize = new Size(400, 400);

            var textBox = new TextBox();
            textBox.TextChanged += TextBox_TextChanged;

            var page = new DocumentPage
            {
                Text = "Tab1",
                Content = new StackLayout
                {
                    Items =
                    {
                        textBox
                    }
                }
            };

            var documentControl = new DocumentControl();
            documentControl.Pages.Add(page);
            Content = documentControl;

            _page = page;
        }

        private void TextBox_TextChanged(object sender, EventArgs e)
        {
            _page.Text += "*";
        }
    }
}

Specifications

  • Version: 2.8.2
  • Platform(s): macOS (probably affects others too, since the Handler is used on many)
  • Operating System(s): macOS 13.6.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant