Skip to content

Input templates #4581

@amottola

Description

@amottola

Hi all,

I see templates are on the roadmap for Input widget, and since I need them on one of my projects, I'd like to give it a try. I'm opening this issue for discussion with the goal of making my first contribution to textual.

I propose to add a template reactive attribute to Input that emulates the behavior of Qt input masks, since this is what I'm used to and I think it allows enough freedom to cover all the use cases mentioned in the roadmap (I see IP address, physical units, currency, credit card) and more. Since Qt input masks are well documented, I'm not going to copy the docs here; just have a look at the link above. They are also effective as they are used in many production environments.

As an extension however, I'd like to add the possibility to specify more than a single blank character after the optional final ;: for this I propose to reuse the placeholder text, which when used in conjunction with template is always made visible even if Input value is not empty. The placeholder covers untyped content only and is dimmed of course. If blank character is specified in the template string, it has a precedence over placeholder.

This should allow for templates suitable to help in the development of the date picker widget (#3576), something like:

date_input = Input(template='0000-00-00', placeholder='YYYY-MM-DD')

Thoughts?

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