-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
keys.go
52 lines (43 loc) · 1.74 KB
/
keys.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package fynedesk
import (
"fyne.io/fyne/v2"
deskDriver "fyne.io/fyne/v2/driver/desktop"
)
const (
// AnyModifier is the shortcut modifier to use if the shortcut should always trigger - use sparingly
AnyModifier fyne.KeyModifier = 0
// UserModifier is the shortcut modifier to use if the shortcut should respect user preference.
// This will be offered as a choice of Alt or Super (Command)
UserModifier fyne.KeyModifier = fyne.KeyModifierSuper << 1
// KeyBrightnessDown is the virtual keyboard key for reducing brightness
KeyBrightnessDown fyne.KeyName = "BrightnessDown"
// KeyBrightnessUp is the virtual keyboard key for increasing brightness
KeyBrightnessUp fyne.KeyName = "BrightnessUp"
// KeyCalculator is available on some multimedia keyboards to open a calculator
KeyCalculator fyne.KeyName = "Calculator"
// KeyVolumeMute is the virtual keyboard key for muting sound
KeyVolumeMute fyne.KeyName = "VolumeMute"
// KeyVolumeDown is the virtual keyboard key for reducing sound level
KeyVolumeDown fyne.KeyName = "VolumeDown"
// KeyVolumeUp is the virtual keyboard key for increasing sound level
KeyVolumeUp fyne.KeyName = "VolumeUp"
)
// Declare conformity with Shortcut interface
var _ fyne.Shortcut = (*Shortcut)(nil)
// Shortcut defines a keyboard shortcut that can be configured by the user
type Shortcut struct {
fyne.KeyName
deskDriver.Modifier
Name string
}
// ShortcutName gets the name of this shortcut - this should be user presentable
func (s *Shortcut) ShortcutName() string {
return s.Name
}
// NewShortcut creates a keyboard shortcut that can be configured by the user
func NewShortcut(name string, key fyne.KeyName, mods fyne.KeyModifier) *Shortcut {
s := &Shortcut{Name: name}
s.KeyName = key
s.Modifier = mods
return s
}