1
1
use gpui:: {
2
- actions, prelude:: FluentBuilder as _, px, App , Context , Entity , EventEmitter , FocusHandle ,
3
- Focusable , InteractiveElement , IntoElement , KeyBinding , ParentElement , RenderOnce ,
2
+ actions, prelude:: FluentBuilder as _, px, App , Context , ElementId , Entity , EventEmitter ,
3
+ FocusHandle , Focusable , InteractiveElement , IntoElement , KeyBinding , ParentElement , RenderOnce ,
4
4
SharedString , Styled , Window ,
5
5
} ;
6
6
@@ -26,6 +26,7 @@ pub fn init(cx: &mut App) {
26
26
27
27
#[ derive( IntoElement ) ]
28
28
pub struct NumberInput {
29
+ id : ElementId ,
29
30
state : Entity < InputState > ,
30
31
placeholder : SharedString ,
31
32
size : Size ,
@@ -35,6 +36,7 @@ impl NumberInput {
35
36
/// Create a new [`NumberInput`] element bind to the [`InputState`].
36
37
pub fn new ( state : & Entity < InputState > ) -> Self {
37
38
Self {
39
+ id : ( "number-input" , state. entity_id ( ) ) . into ( ) ,
38
40
state : state. clone ( ) ,
39
41
size : Size :: default ( ) ,
40
42
placeholder : SharedString :: default ( ) ,
@@ -115,6 +117,7 @@ impl RenderOnce for NumberInput {
115
117
} ;
116
118
117
119
h_flex ( )
120
+ . id ( self . id )
118
121
. key_context ( KEY_CONTENT )
119
122
. on_action ( window. listener_for ( & self . state , InputState :: on_action_increment) )
120
123
. on_action ( window. listener_for ( & self . state , InputState :: on_action_decrement) )
@@ -142,7 +145,7 @@ impl RenderOnce for NumberInput {
142
145
}
143
146
} ) ,
144
147
)
145
- . child ( TextInput :: new ( & self . state ) . no_gap ( ) )
148
+ . child ( TextInput :: new ( & self . state ) . appearance ( false ) . no_gap ( ) )
146
149
. child (
147
150
Button :: new ( "plus" )
148
151
. ghost ( )
0 commit comments