Skip to content

MaskedInput does not highlight the selected text #5495

Open
@TomJGooding

Description

@TomJGooding
Contributor

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()

Activity

github-actions

github-actions commented on Jan 25, 2025

@github-actions

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

added a commit that references this issue on Jan 25, 2025
f207df0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @TomJGooding

      Issue actions

        `MaskedInput` does not highlight the selected text · Issue #5495 · Textualize/textual