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

add LimitedWidthEntry widget #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

kgolding
Copy link

An extended Entry widget that sets the width, and limits entry of a given number of chars.

@andydotxyz
Copy link
Member

andydotxyz commented Mar 30, 2022

Thanks for the contribution. Looking at the implementation of MinSize it seems like this may be a "FixedWidthEntry" rather than a "LimitedWidthEntry"?

I'd also prefer the use of "runes" instead of "chars" I think, to be consistent with what go does...
Using runes would support multi-byte characters too. Should be a lot easier to test with recent Fyne as the font support is much better.

//
// Implements: fyne.Focusable
func (e *LimitedWidthEntry) TypedRune(r rune) {
if e.CharsWide < 1 || len(e.Text) < e.CharsWide {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If moving to rune rather than chars then len([]rune(e.Text)) will count codepoint/glyph instead of bytes.

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was not marked as changes requested earlier when the changes were requested.

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 this pull request may close these issues.

None yet

2 participants