File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -174,15 +174,22 @@ impl SearchBar {
174174
175175 /// Show the search bar and focus the input
176176 /// Selects all existing text so typing replaces it
177+ /// If there's existing text, triggers the search callback to highlight matches
177178 pub fn show ( & mut self ) {
178179 self . group . show ( ) ;
179- let len = self . input . value ( ) . len ( ) as i32 ;
180+ let text = self . input . value ( ) ;
181+ let len = text. len ( ) as i32 ;
180182 self . input . take_focus ( ) . ok ( ) ;
181183 if len > 0 {
182184 // In FLTK, position is cursor, mark is selection anchor
183185 // Setting position to end first, then mark to 0 selects all
184186 self . input . set_position ( len) . ok ( ) ;
185187 self . input . set_mark ( 0 ) . ok ( ) ;
188+
189+ // Trigger the search callback with existing text to highlight matches
190+ if let Some ( cb) = & mut * self . on_search . borrow_mut ( ) {
191+ cb ( text) ;
192+ }
186193 }
187194 }
188195
You can’t perform that action at this time.
0 commit comments