Changed keyboard back to numerical one
This commit is contained in:
parent
b38cb92788
commit
51a62c2e6d
1 changed files with 39 additions and 2 deletions
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"fyne.io/fyne/v2/app"
|
"fyne.io/fyne/v2/app"
|
||||||
|
@ -10,10 +11,46 @@ import (
|
||||||
"github.com/gocolly/colly/v2"
|
"github.com/gocolly/colly/v2"
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
|
|
||||||
"fyne.io/fyne/v2/layout"
|
"fyne.io/fyne/v2/layout"
|
||||||
|
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"fyne.io/fyne/v2/driver/mobile"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type numericalEntry struct {
|
||||||
|
widget.Entry
|
||||||
|
}
|
||||||
|
|
||||||
|
func newNumericalEntry() *numericalEntry {
|
||||||
|
entry := &numericalEntry{}
|
||||||
|
entry.ExtendBaseWidget(entry)
|
||||||
|
return entry
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *numericalEntry) TypedRune(r rune) {
|
||||||
|
if (r >= '0' && r <= '9') || r == '.' || r == ',' {
|
||||||
|
e.Entry.TypedRune(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *numericalEntry) TypedShortcut(shortcut fyne.Shortcut) {
|
||||||
|
paste, ok := shortcut.(*fyne.ShortcutPaste)
|
||||||
|
if !ok {
|
||||||
|
e.Entry.TypedShortcut(shortcut)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
content := paste.Clipboard.Content()
|
||||||
|
if _, err := strconv.ParseFloat(content, 64); err == nil {
|
||||||
|
e.Entry.TypedShortcut(shortcut)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *numericalEntry) Keyboard() mobile.KeyboardType {
|
||||||
|
return mobile.NumberKeyboard
|
||||||
|
}
|
||||||
|
|
||||||
type vehicle struct {
|
type vehicle struct {
|
||||||
producer string
|
producer string
|
||||||
model string
|
model string
|
||||||
|
@ -97,7 +134,7 @@ func main() {
|
||||||
w := a.NewWindow("ZTM vehicles")
|
w := a.NewWindow("ZTM vehicles")
|
||||||
|
|
||||||
entryLabel := widget.NewLabel("Podaj numer taborowy pojazdu:")
|
entryLabel := widget.NewLabel("Podaj numer taborowy pojazdu:")
|
||||||
entry := widget.NewEntry()
|
entry := newNumericalEntry()
|
||||||
output := widget.NewLabel("")
|
output := widget.NewLabel("")
|
||||||
output.Wrapping = fyne.TextWrapWord
|
output.Wrapping = fyne.TextWrapWord
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue