@@ -20,7 +20,7 @@ use crate::components::fps::FrameHistory;
20
20
use std:: time:: { Instant } ;
21
21
use eframe:: { CreationContext , NativeOptions } ;
22
22
use eframe:: Theme :: Light ;
23
- use egui:: { Align2 , Button , Color32 , ComboBox , Context , IconData , Id , Label , LayerId , Order , RichText , Sense , Separator , TextEdit , TextStyle , Vec2 , Widget } ;
23
+ use egui:: { Align2 , Button , Color32 , ComboBox , Context , IconData , Id , Key , Label , LayerId , Order , RichText , Sense , Separator , TextEdit , TextStyle , Vec2 , Widget } ;
24
24
use json_flat_parser:: { FlatJsonValue , JSONParser , ParseOptions , ValueType } ;
25
25
use crate :: panels:: { SelectColumnsPanel } ;
26
26
use crate :: array_table:: { ArrayTable , ScrollToRowMode } ;
@@ -110,7 +110,7 @@ struct MyApp {
110
110
selected_pointer : Option < String > ,
111
111
min_depth : u8 ,
112
112
unsaved_changes : bool ,
113
- show_fps : bool
113
+ show_fps : bool ,
114
114
}
115
115
116
116
impl MyApp {
@@ -236,6 +236,19 @@ impl MyApp {
236
236
self . table = None ;
237
237
}
238
238
}
239
+
240
+ fn goto_next_occurrence ( table : & mut ArrayTable ) -> bool {
241
+ if table. matching_rows . len ( ) == 0 {
242
+ return false ;
243
+ }
244
+ if table. matching_row_selected == table. matching_rows . len ( ) - 1 {
245
+ table. matching_row_selected = 0 ;
246
+ } else {
247
+ table. matching_row_selected += 1 ;
248
+ }
249
+ table. changed_matching_row_selected = true ;
250
+ true
251
+ }
239
252
}
240
253
241
254
fn set_open ( open : & mut BTreeSet < String > , key : & ' static str , is_open : bool ) {
@@ -261,7 +274,7 @@ impl eframe::App for MyApp {
261
274
title = format ! ( "{} - {:.2}" , title, self . frame_history. fps( ) )
262
275
}
263
276
264
- ctx. send_viewport_cmd_to ( ctx. parent_viewport_id ( ) , egui:: ViewportCommand :: Title ( title) , ) ;
277
+ ctx. send_viewport_cmd_to ( ctx. parent_viewport_id ( ) , egui:: ViewportCommand :: Title ( title) ) ;
265
278
266
279
self . windows ( ctx) ;
267
280
egui:: TopBottomPanel :: top ( "top" ) . show ( ctx, |ui| {
@@ -334,12 +347,7 @@ impl eframe::App for MyApp {
334
347
table. changed_matching_row_selected = true ;
335
348
}
336
349
if response_next. clicked ( ) {
337
- if table. matching_row_selected == table. matching_rows . len ( ) - 1 {
338
- table. matching_row_selected = 0 ;
339
- } else {
340
- table. matching_row_selected += 1 ;
341
- }
342
- table. changed_matching_row_selected = true ;
350
+ Self :: goto_next_occurrence ( table) ;
343
351
}
344
352
}
345
353
( scroll_to_row_mode_response, scroll_to_row_response)
@@ -356,6 +364,10 @@ impl eframe::App for MyApp {
356
364
if table. scroll_to_row . is_empty ( ) {
357
365
table. reset_search ( ) ;
358
366
}
367
+ } else if scroll_to_row_response. lost_focus ( ) && ctx. input ( |i| i. key_pressed ( Key :: Enter ) ) {
368
+ if Self :: goto_next_occurrence ( table) {
369
+ scroll_to_row_response. request_focus ( ) ;
370
+ }
359
371
}
360
372
if scroll_to_row_mode_response. inner . is_some ( ) && scroll_to_row_mode_response. inner . unwrap ( ) {
361
373
table. reset_search ( ) ;
0 commit comments