Skip to content

Commit

Permalink
do not display toolbar navigation on web in content since it is super…
Browse files Browse the repository at this point in the history
…seded by browser navigation (#1279)
  • Loading branch information
kkoreilly committed Nov 20, 2024
1 parent 06e3654 commit 088b4f5
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions content/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"cogentcore.org/core/icons"
"cogentcore.org/core/keymap"
"cogentcore.org/core/styles"
"cogentcore.org/core/system"
"cogentcore.org/core/tree"
)

Expand Down Expand Up @@ -267,28 +268,31 @@ func (ct *Content) makeCategories() {
}

func (ct *Content) MakeToolbar(p *tree.Plan) {
tree.Add(p, func(w *core.Button) {
w.SetIcon(icons.ArrowBack).SetKey(keymap.HistPrev)
w.SetTooltip("Back")
w.Updater(func() {
w.SetEnabled(ct.historyIndex > 0)
})
w.OnClick(func(e events.Event) {
ct.historyIndex--
ct.open(ct.history[ct.historyIndex].URL, false) // do not add to history while navigating history
})
})
tree.Add(p, func(w *core.Button) {
w.SetIcon(icons.ArrowForward).SetKey(keymap.HistNext)
w.SetTooltip("Forward")
w.Updater(func() {
w.SetEnabled(ct.historyIndex < len(ct.history)-1)
// Superseded by browser navigation on web.
if core.TheApp.Platform() != system.Web {
tree.Add(p, func(w *core.Button) {
w.SetIcon(icons.ArrowBack).SetKey(keymap.HistPrev)
w.SetTooltip("Back")
w.Updater(func() {
w.SetEnabled(ct.historyIndex > 0)
})
w.OnClick(func(e events.Event) {
ct.historyIndex--
ct.open(ct.history[ct.historyIndex].URL, false) // do not add to history while navigating history
})
})
w.OnClick(func(e events.Event) {
ct.historyIndex++
ct.open(ct.history[ct.historyIndex].URL, false) // do not add to history while navigating history
tree.Add(p, func(w *core.Button) {
w.SetIcon(icons.ArrowForward).SetKey(keymap.HistNext)
w.SetTooltip("Forward")
w.Updater(func() {
w.SetEnabled(ct.historyIndex < len(ct.history)-1)
})
w.OnClick(func(e events.Event) {
ct.historyIndex++
ct.open(ct.history[ct.historyIndex].URL, false) // do not add to history while navigating history
})
})
})
}
tree.Add(p, func(w *core.Button) {
w.SetIcon(icons.Search).SetKey(keymap.Menu)
w.SetTooltip("Search")
Expand Down

0 comments on commit 088b4f5

Please sign in to comment.