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

Centering TextInput #348

Closed
imjasonmiller opened this issue May 18, 2020 · 3 comments
Closed

Centering TextInput #348

imjasonmiller opened this issue May 18, 2020 · 3 comments
Labels
feature New feature or request good first issue Good for newcomers text widget
Milestone

Comments

@imjasonmiller
Copy link

Hi!

I wondered whether it is possible to center (x- and y) the contents of a TextInput?

I've currently placed the TextInput inside of a Container with the align_x and align_y methods, but while this seems to work for Text, with .horizontal_alignment(HorizontalAlignment::Center), it fails for TextInput.

I'm trying to build the UI below:

image

This is where I'm currently at:

image

The content for each TextInput is aligned to the left. Can this be centered in some way? I tried applying .width(Length::Shrink), thinking it might size it according to the value/placeholder length, but the element seems to disappear in its entirety in that case.

Thank you for creating this library. It's easy to use for a Rust beginner so far.

@hecrj hecrj added the feature New feature or request label May 18, 2020
@hecrj
Copy link
Member

hecrj commented May 18, 2020

That looks great!

It's not currently possible to center the contents of a TextInput, but it's definitely something we should implement eventually.

I imagine an horizontal_alignment method would work well and be consistent with the Text widget. The implementation will be a bit tricky because the alignment will affect the logic of text measurements for mouse interaction and text selection.

I will try to give it a shot soon, but I believe this could be a good issue for anyone that wants to get familiar with the internals of the library!

@hecrj hecrj added the good first issue Good for newcomers label May 18, 2020
@hecrj hecrj added this to the 0.2.0 milestone May 18, 2020
@phoenisx
Copy link

I want to work on it. Never worked properly on any open source before, so not sure how long will it take, but I would love to finish it.

Will give it a try this weekend.

If I have any doubts will post it here for better reference 👍

phoenisx pushed a commit to phoenisx/iced that referenced this issue May 31, 2020
phoenisx added a commit to phoenisx/iced that referenced this issue Jun 2, 2020
phoenisx added a commit to phoenisx/iced that referenced this issue Jun 2, 2020
phoenisx added a commit to phoenisx/iced that referenced this issue Jun 3, 2020
phoenisx added a commit to phoenisx/iced that referenced this issue Jun 3, 2020
phoenisx added a commit to phoenisx/iced that referenced this issue Jun 4, 2020
phoenisx added a commit to phoenisx/iced that referenced this issue Jun 4, 2020
phoenisx added a commit to phoenisx/iced that referenced this issue Jun 4, 2020
phoenisx added a commit to phoenisx/iced that referenced this issue Jun 4, 2020
phoenisx added a commit to phoenisx/iced that referenced this issue Jun 4, 2020
@hecrj hecrj modified the milestones: 0.2.0, 0.3.0 Nov 26, 2020
@hecrj hecrj modified the milestones: 0.3.0, 0.4.0 Mar 31, 2021
@hecrj hecrj modified the milestones: 0.4.0, 0.5.0 Apr 12, 2022
@hecrj hecrj modified the milestones: 0.5.0, 0.6.0 Nov 9, 2022
@hecrj hecrj modified the milestones: 0.6.0, 0.7.0 Dec 7, 2022
@hecrj hecrj modified the milestones: 0.7.0, 0.8.0 Jan 14, 2023
@hecrj hecrj modified the milestones: 0.8.0, 0.9.0 Feb 18, 2023
@hecrj hecrj modified the milestones: 0.9.0, 0.10.0 Apr 13, 2023
@hecrj hecrj modified the milestones: 0.10.0, 0.11.0 Jul 28, 2023
@hecrj hecrj modified the milestones: 0.12, 0.13 Feb 11, 2024
@hecrj
Copy link
Member

hecrj commented Sep 18, 2024

Fixed by #2535.

@hecrj hecrj closed this as completed Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request good first issue Good for newcomers text widget
Projects
None yet
Development

No branches or pull requests

3 participants