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

MaskedInput does not highlight the selected text #5495

Open
TomJGooding opened this issue Jan 25, 2025 · 1 comment · May be fixed by #5496
Open

MaskedInput does not highlight the selected text #5495

TomJGooding opened this issue Jan 25, 2025 · 1 comment · May be fixed by #5496

Comments

@TomJGooding
Copy link
Contributor

TomJGooding commented Jan 25, 2025

Following on from #5493, I think this also reveals another issue with the MaskedInput:

Edit: Sorry just to clarify, this is relevant to initial focus or focus on tab. Clicking to focus the input seems to place the cursor without any text selection.

from textual.app import App, ComposeResult
from textual.widgets import Input, Label, MaskedInput


class InputSelectionApp(App):
    CSS = """
    Label {
        margin: 1;
    }
    """

    def compose(self) -> ComposeResult:
        yield Label("Input text is now selected on focus by default.")

        yield Label(
            "This is obvious to the user for the Input widget "
            "where the selection is highlighted:"
        )
        yield Input("text")

        yield Label(
            "But not the MaskedInput, "
            "which is confusing when typing will overwrite the previous text:"
        )
        yield MaskedInput(template="AAAAAAAA;-", value="text")


if __name__ == "__main__":
    app = InputSelectionApp()
    app.run()
Copy link

We found the following entry in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

TomJGooding added a commit to TomJGooding/textual that referenced this issue Jan 25, 2025
@TomJGooding TomJGooding linked a pull request Jan 25, 2025 that will close this issue
3 tasks
JonathanPlasse pushed a commit to JonathanPlasse/textual that referenced this issue Feb 1, 2025
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

Successfully merging a pull request may close this issue.

1 participant