add more restrictions to year entry field in album filters
This commit is contained in:
@@ -88,7 +88,8 @@ func NewAlbumFilterPopup(filter *AlbumFilterButton) *AlbumFilterPopup {
|
|||||||
|
|
||||||
// setup min and max year filters
|
// setup min and max year filters
|
||||||
yearValidator := func(curText, selText string, r rune) bool {
|
yearValidator := func(curText, selText string, r rune) bool {
|
||||||
return unicode.IsDigit(r) && (len(selText) > 0 || len(curText) <= 3)
|
l := len(curText) - len(selText)
|
||||||
|
return unicode.IsDigit(r) && l <= 3 && (l > 0 || r != '0')
|
||||||
}
|
}
|
||||||
minYear := NewTextRestrictedEntry(yearValidator)
|
minYear := NewTextRestrictedEntry(yearValidator)
|
||||||
minYear.SetMinCharWidth(4)
|
minYear.SetMinCharWidth(4)
|
||||||
|
|||||||
@@ -32,6 +32,13 @@ func (e *TextRestrictedEntry) TypedRune(r rune) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *TextRestrictedEntry) TypedShortcut(s fyne.Shortcut) {
|
||||||
|
if s.ShortcutName() == (&fyne.ShortcutPaste{}).ShortcutName() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
e.TypedShortcut(s)
|
||||||
|
}
|
||||||
|
|
||||||
func (e *TextRestrictedEntry) SetMinCharWidth(numChars int) {
|
func (e *TextRestrictedEntry) SetMinCharWidth(numChars int) {
|
||||||
e.minWidth = theme.Padding()*2 + fyne.MeasureText(strings.Repeat("W", numChars),
|
e.minWidth = theme.Padding()*2 + fyne.MeasureText(strings.Repeat("W", numChars),
|
||||||
fyne.CurrentApp().Settings().Theme().Size(theme.SizeNameText), e.TextStyle).Width
|
fyne.CurrentApp().Settings().Theme().Size(theme.SizeNameText), e.TextStyle).Width
|
||||||
|
|||||||
Reference in New Issue
Block a user