This repository has been archived by the owner on Sep 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update gui and add support for all the data fields
- Loading branch information
Showing
3 changed files
with
111 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package gui | ||
|
||
import ( | ||
"fyne.io/fyne" | ||
"fyne.io/fyne/widget" | ||
) | ||
|
||
// ExtendedEntry is used to make an entry that reacts to key presses. | ||
type ExtendedEntry struct { | ||
widget.Entry | ||
*Action | ||
} | ||
|
||
// Action handles the Button press action. | ||
type Action struct { | ||
widget.Button | ||
} | ||
|
||
// TypedKey handles the key presses inside our UsernameEntry and uses Action to press the linked button. | ||
func (e *ExtendedEntry) TypedKey(ev *fyne.KeyEvent) { | ||
switch ev.Name { | ||
case fyne.KeyReturn: | ||
e.Action.Button.OnTapped() | ||
default: | ||
e.Entry.TypedKey(ev) | ||
} | ||
} | ||
|
||
// NewExtendedEntry creates an ExtendedEntry button. | ||
func NewExtendedEntry(password bool) *ExtendedEntry { | ||
entry := &ExtendedEntry{} | ||
|
||
// Extend the base widget. | ||
entry.ExtendBaseWidget(entry) | ||
|
||
// Check if we are creating a password entry. | ||
if password { | ||
entry.Password = true | ||
} | ||
|
||
return entry | ||
} | ||
|
||
// NewEntryWithPlaceholder makes it easy to create entry widgets with placeholders. | ||
func NewEntryWithPlaceholder(text string) *widget.Entry { | ||
entry := widget.NewEntry() | ||
entry.SetPlaceHolder(text) | ||
|
||
return entry | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters