@@ -37,6 +37,7 @@ pub struct TextInputComponent {
37
37
default_msg : String ,
38
38
msg : String ,
39
39
visible : bool ,
40
+ selected : Option < bool > ,
40
41
show_char_count : bool ,
41
42
theme : SharedTheme ,
42
43
key_config : SharedKeyConfig ,
@@ -64,6 +65,7 @@ impl TextInputComponent {
64
65
show_char_count,
65
66
title : title. to_string ( ) ,
66
67
default_msg : default_msg. to_string ( ) ,
68
+ selected : None ,
67
69
cursor_position : 0 ,
68
70
input_type : InputType :: Multiline ,
69
71
current_area : Cell :: new ( Rect :: default ( ) ) ,
@@ -102,6 +104,11 @@ impl TextInputComponent {
102
104
self . embed = true ;
103
105
}
104
106
107
+ ///
108
+ pub fn enabled ( & mut self , enable : bool ) {
109
+ self . selected = Some ( enable) ;
110
+ }
111
+
105
112
/// Move the cursor right one char.
106
113
fn incr_cursor ( & mut self ) {
107
114
if let Some ( pos) = self . next_char_position ( ) {
@@ -229,7 +236,8 @@ impl TextInputComponent {
229
236
}
230
237
231
238
fn get_draw_text ( & self ) -> Text {
232
- let style = self . theme . text ( true , false ) ;
239
+ let style =
240
+ self . theme . text ( self . selected . unwrap_or ( true ) , false ) ;
233
241
234
242
let mut txt = Text :: default ( ) ;
235
243
// The portion of the text before the cursor is added
@@ -367,7 +375,10 @@ impl DrawableComponent for TextInputComponent {
367
375
let txt = if self . msg . is_empty ( ) {
368
376
Text :: styled (
369
377
self . default_msg . as_str ( ) ,
370
- self . theme . text ( false , false ) ,
378
+ self . theme . text (
379
+ self . selected . unwrap_or_default ( ) ,
380
+ false ,
381
+ ) ,
371
382
)
372
383
} else {
373
384
self . get_draw_text ( )
0 commit comments