@@ -7,7 +7,10 @@ use std::{
7
7
#[ cfg( not( target_arch = "wasm32" ) ) ]
8
8
use anyhow:: { bail, Context } ;
9
9
use data:: filter:: { Comparator , FieldSpecifier , FilterConfig , FilterOn } ;
10
- use egui:: { Align , KeyboardShortcut } ;
10
+ use egui:: {
11
+ text:: { CCursor , CCursorRange } ,
12
+ Align , KeyboardShortcut ,
13
+ } ;
11
14
use egui_extras:: { Column , TableBuilder } ;
12
15
use log:: info;
13
16
use shortcut:: Shortcuts ;
@@ -506,13 +509,30 @@ impl LogViewerApp {
506
509
is_case_sensitive,
507
510
comparator,
508
511
} = filter;
512
+
509
513
ui. label ( "Search Key: " ) ;
510
- let search_key_text_edit = ui . text_edit_singleline ( search_key) ;
514
+ let mut search_key_text_edit = egui :: TextEdit :: singleline ( search_key) . show ( ui ) ;
511
515
if self . should_focus_search {
512
516
self . should_focus_search = false ;
513
- search_key_text_edit. request_focus ( ) ;
517
+
518
+ // Set focus on edit
519
+ search_key_text_edit. response . request_focus ( ) ;
520
+
521
+ // Select all text
522
+ search_key_text_edit
523
+ . state
524
+ . cursor
525
+ . set_char_range ( Some ( CCursorRange :: two (
526
+ CCursor :: new ( 0 ) ,
527
+ CCursor :: new ( search_key. len ( ) ) ,
528
+ ) ) ) ;
529
+
530
+ // Apply selection changes
531
+ search_key_text_edit
532
+ . state
533
+ . store ( ui. ctx ( ) , search_key_text_edit. response . id ) ;
514
534
}
515
- if search_key_text_edit. lost_focus ( )
535
+ if search_key_text_edit. response . lost_focus ( )
516
536
&& ui. input ( |i| i. key_pressed ( egui:: Key :: Enter ) )
517
537
{
518
538
should_apply_filter = true ;
0 commit comments