Skip to content

MaskedInput does not highlight the selected text #5495

Open
@TomJGooding

Description

@TomJGooding

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions