Skip to content

Commit

Permalink
Merge pull request #4251 from xypwn/develop
Browse files Browse the repository at this point in the history
Add Entry undo/redo functionality
  • Loading branch information
Jacalz authored Oct 2, 2023
2 parents 8d541a3 + 0abac16 commit df6e029
Show file tree
Hide file tree
Showing 10 changed files with 435 additions and 7 deletions.
6 changes: 6 additions & 0 deletions internal/driver/glfw/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,12 @@ func (w *window) triggersShortcut(localizedKeyName fyne.KeyName, key fyne.KeyNam
}
if modifier == ctrlMod {
switch keyName {
case fyne.KeyZ:
// detect undo shortcut
shortcut = &fyne.ShortcutUndo{}
case fyne.KeyY:
// detect redo shortcut
shortcut = &fyne.ShortcutRedo{}
case fyne.KeyV:
// detect paste shortcut
shortcut = &fyne.ShortcutPaste{
Expand Down
52 changes: 52 additions & 0 deletions shortcut.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,55 @@ func (se *ShortcutSelectAll) Mod() KeyModifier {
func (se *ShortcutSelectAll) ShortcutName() string {
return "SelectAll"
}

// ShortcutUndo describes a shortcut undo action.
//
// Since: 2.5
type ShortcutUndo struct{}

var _ KeyboardShortcut = (*ShortcutUndo)(nil)

// Key returns the KeyName for this shortcut.
//
// Implements: KeyboardShortcut
func (se *ShortcutUndo) Key() KeyName {
return KeyZ
}

// Mod returns the KeyModifier for this shortcut.
//
// Implements: KeyboardShortcut
func (se *ShortcutUndo) Mod() KeyModifier {
return KeyModifierShortcutDefault
}

// ShortcutName returns the shortcut name
func (se *ShortcutUndo) ShortcutName() string {
return "Undo"
}

// ShortcutRedo describes a shortcut redo action.
//
// Since: 2.5
type ShortcutRedo struct{}

var _ KeyboardShortcut = (*ShortcutRedo)(nil)

// Key returns the KeyName for this shortcut.
//
// Implements: KeyboardShortcut
func (se *ShortcutRedo) Key() KeyName {
return KeyY
}

// Mod returns the KeyModifier for this shortcut.
//
// Implements: KeyboardShortcut
func (se *ShortcutRedo) Mod() KeyModifier {
return KeyModifierShortcutDefault
}

// ShortcutName returns the shortcut name
func (se *ShortcutRedo) ShortcutName() string {
return "Redo"
}
Loading

0 comments on commit df6e029

Please sign in to comment.