add Ctrl+(num) shortcuts for the navigation buttons
This commit is contained in:
@@ -123,6 +123,13 @@ func (b *BrowsingPane) EnableNavigationButtons() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *BrowsingPane) ActivateNavigationButton(num int) {
|
||||||
|
if num < len(b.navBtnsContainer.Objects) {
|
||||||
|
btn := b.navBtnsContainer.Objects[num].(*widget.Button)
|
||||||
|
btn.OnTapped()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (b *BrowsingPane) GetSearchBarIfAny() fyne.Focusable {
|
func (b *BrowsingPane) GetSearchBarIfAny() fyne.Focusable {
|
||||||
if s, ok := b.curPage.(Searchable); ok {
|
if s, ok := b.curPage.(Searchable); ok {
|
||||||
return s.SearchWidget()
|
return s.SearchWidget()
|
||||||
|
|||||||
@@ -18,6 +18,16 @@ var (
|
|||||||
ShortcutForward = desktop.CustomShortcut{KeyName: fyne.KeyRight, Modifier: os.AltModifier}
|
ShortcutForward = desktop.CustomShortcut{KeyName: fyne.KeyRight, Modifier: os.AltModifier}
|
||||||
ShortcutReload = desktop.CustomShortcut{KeyName: fyne.KeyR, Modifier: os.ControlModifier}
|
ShortcutReload = desktop.CustomShortcut{KeyName: fyne.KeyR, Modifier: os.ControlModifier}
|
||||||
ShortcutSearch = desktop.CustomShortcut{KeyName: fyne.KeyF, Modifier: os.ControlModifier}
|
ShortcutSearch = desktop.CustomShortcut{KeyName: fyne.KeyF, Modifier: os.ControlModifier}
|
||||||
|
|
||||||
|
ShortcutNavOne = desktop.CustomShortcut{KeyName: fyne.Key1, Modifier: os.ControlModifier}
|
||||||
|
ShortcutNavTwo = desktop.CustomShortcut{KeyName: fyne.Key2, Modifier: os.ControlModifier}
|
||||||
|
ShortcutNavThree = desktop.CustomShortcut{KeyName: fyne.Key3, Modifier: os.ControlModifier}
|
||||||
|
ShortcutNavFour = desktop.CustomShortcut{KeyName: fyne.Key4, Modifier: os.ControlModifier}
|
||||||
|
ShortcutNavFive = desktop.CustomShortcut{KeyName: fyne.Key5, Modifier: os.ControlModifier}
|
||||||
|
ShortcutNavSix = desktop.CustomShortcut{KeyName: fyne.Key6, Modifier: os.ControlModifier}
|
||||||
|
|
||||||
|
NavShortcuts = []desktop.CustomShortcut{ShortcutNavOne, ShortcutNavTwo, ShortcutNavThree,
|
||||||
|
ShortcutNavFour, ShortcutNavFive, ShortcutNavSix}
|
||||||
)
|
)
|
||||||
|
|
||||||
type MainWindow struct {
|
type MainWindow struct {
|
||||||
@@ -120,6 +130,14 @@ func (m *MainWindow) addShortcuts() {
|
|||||||
m.BrowsingPane.SelectAll()
|
m.BrowsingPane.SelectAll()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
for i, ns := range NavShortcuts {
|
||||||
|
m.Canvas().AddShortcut(&ns, func(i int) func(fyne.Shortcut) {
|
||||||
|
return func(fyne.Shortcut) {
|
||||||
|
m.BrowsingPane.ActivateNavigationButton(i)
|
||||||
|
}
|
||||||
|
}(i))
|
||||||
|
}
|
||||||
|
|
||||||
m.Canvas().SetOnTypedKey(func(e *fyne.KeyEvent) {
|
m.Canvas().SetOnTypedKey(func(e *fyne.KeyEvent) {
|
||||||
if e.Name == fyne.KeySpace {
|
if e.Name == fyne.KeySpace {
|
||||||
m.App.Player.PlayPause()
|
m.App.Player.PlayPause()
|
||||||
|
|||||||
Reference in New Issue
Block a user