@@ -38,42 +38,49 @@ func (ct *Content) MakeToolbar(p *tree.Plan) {
3838 w .SetIcon (icons .Icon (core .AppIcon ))
3939 w .SetTooltip ("Home" )
4040 w .OnClick (func (e events.Event ) {
41- ct .Open ("" )
41+ ct .OpenEvent ("" , e )
4242 })
4343 })
4444 // Superseded by browser navigation on web.
4545 if core .TheApp .Platform () != system .Web {
4646 tree .Add (p , func (w * core.Button ) {
47+ ct .toolbar = w .Parent .(* core.Toolbar )
4748 w .SetIcon (icons .ArrowBack ).SetKey (keymap .HistPrev )
4849 w .SetTooltip ("Back" )
4950 w .Updater (func () {
50- w .SetEnabled (ct .historyIndex > 0 )
51+ w .SetEnabled (ct .historyHasBack () )
5152 })
5253 w .OnClick (func (e events.Event ) {
53- ct .historyIndex --
54- ct .open (ct .history [ct .historyIndex ].URL , false ) // do not add to history while navigating history
54+ ct .historyBack ()
55+ if ct .toolbar != nil {
56+ ct .toolbar .Update ()
57+ }
5558 })
5659 })
5760 tree .Add (p , func (w * core.Button ) {
5861 w .SetIcon (icons .ArrowForward ).SetKey (keymap .HistNext )
5962 w .SetTooltip ("Forward" )
6063 w .Updater (func () {
61- w .SetEnabled (ct .historyIndex < len ( ct . history ) - 1 )
64+ w .SetEnabled (ct .historyHasForward () )
6265 })
6366 w .OnClick (func (e events.Event ) {
64- ct .historyIndex ++
65- ct .open (ct .history [ct .historyIndex ].URL , false ) // do not add to history while navigating history
67+ ct .historyForward ()
68+ if ct .toolbar != nil {
69+ ct .toolbar .Update ()
70+ }
6671 })
6772 })
6873 }
6974 tree .Add (p , func (w * core.Button ) {
70- w .SetText ("Search" ).SetIcon (icons .Search ).SetKey (keymap .Menu )
75+ find := keymap .Find .Chord ().Label ()
76+ w .SetText ("Search" ).SetIcon (icons .Search ).SetKey (keymap .Menu ).
77+ SetTooltip ("Search for pages by name (use " + find + " or context menu to search within current page)" )
7178 w .Styler (func (s * styles.Style ) {
7279 s .Background = colors .Scheme .SurfaceVariant
7380 s .Padding .Right .Em (5 )
7481 })
7582 w .OnClick (func (e events.Event ) {
76- ct .Scene .MenuSearchDialog ("Search " , "Search " + core .TheApp .Name ())
83+ ct .Scene .MenuSearchDialog ("Page search " , "Search " + core .TheApp .Name ())
7784 })
7885 })
7986}
@@ -88,6 +95,23 @@ func (ct *Content) MakeToolbarPDF(p *tree.Plan) {
8895 })
8996}
9097
98+ // MakeToolbarSearch adds a within-page search button to the toolbar.
99+ // This is optional.
100+ func (ct * Content ) MakeToolbarSearch (p * tree.Plan ) {
101+ tree .Add (p , func (w * core.Button ) {
102+ w .SetText ("Search" ).SetIcon (icons .Search ).SetKey (keymap .Find ).
103+ SetTooltip ("Search within content of current page" )
104+ w .Styler (func (s * styles.Style ) {
105+ s .Background = colors .Scheme .SurfaceVariant
106+ s .Padding .Right .Em (5 )
107+ })
108+ w .OnClick (func (e events.Event ) {
109+ e .SetHandled ()
110+ core .Search (ct .rightFrame , core .LastSearch , core .LastUseCase )
111+ })
112+ })
113+ }
114+
91115func (ct * Content ) MenuSearch (items * []core.ChooserItem ) {
92116 newItems := make ([]core.ChooserItem , len (ct .pages ))
93117 for i , pg := range ct .pages {
@@ -105,12 +129,12 @@ func (ct *Content) MenuSearch(items *[]core.ChooserItem) {
105129
106130// makeBottomButtons makes the previous and next buttons if relevant.
107131func (ct * Content ) makeBottomButtons (p * tree.Plan ) {
108- if len (ct .currentPage .Categories ) == 0 {
132+ if len (ct .current . Page .Categories ) == 0 {
109133 return
110134 }
111- cat := ct .currentPage .Categories [0 ]
135+ cat := ct .current . Page .Categories [0 ]
112136 pages := ct .pagesByCategory [cat ]
113- idx := slices .Index (pages , ct .currentPage )
137+ idx := slices .Index (pages , ct .current . Page )
114138
115139 ct .prevPage , ct .nextPage = nil , nil
116140
0 commit comments