@@ -35,6 +35,9 @@ enum SwatchType {
35
35
Hsl ,
36
36
}
37
37
38
+ #[ derive( Component , Clone , Copy ) ]
39
+ struct DemoDisabledButton ;
40
+
38
41
fn main ( ) {
39
42
App :: new ( )
40
43
. add_plugins ( ( DefaultPlugins , FeathersPlugins ) )
@@ -168,7 +171,7 @@ fn demo_root(commands: &mut Commands) -> impl Bundle {
168
171
) ) ,
169
172
..default ( )
170
173
} ,
171
- InteractionDisabled ,
174
+ ( InteractionDisabled , DemoDisabledButton ) ,
172
175
Spawn ( ( Text :: new( "Disabled" ) , ThemedText ) )
173
176
) ,
174
177
button(
@@ -249,7 +252,25 @@ fn demo_root(commands: &mut Commands) -> impl Bundle {
249
252
) ,
250
253
checkbox(
251
254
CheckboxProps {
252
- on_change: Callback :: Ignore ,
255
+ on_change: Callback :: System ( commands. register_system(
256
+ |change: In <ValueChange <bool >>,
257
+ query: Query <Entity , With <DemoDisabledButton >>,
258
+ mut commands: Commands | {
259
+ info!( "Checkbox clicked!" ) ;
260
+ let mut button = commands. entity( query. single( ) . unwrap( ) ) ;
261
+ if change. value {
262
+ button. insert( InteractionDisabled ) ;
263
+ } else {
264
+ button. remove:: <InteractionDisabled >( ) ;
265
+ }
266
+ let mut checkbox = commands. entity( change. source) ;
267
+ if change. value {
268
+ checkbox. insert( Checked ) ;
269
+ } else {
270
+ checkbox. remove:: <Checked >( ) ;
271
+ }
272
+ }
273
+ ) ) ,
253
274
} ,
254
275
Checked ,
255
276
Spawn ( ( Text :: new( "Checkbox" ) , ThemedText ) )
0 commit comments