# Objective Define a framework for handling keyboard focus and bubbled keyboard events, as discussed in #15374. ## Solution Introduces a new crate, `bevy_input_focus`. This crate provides: * A resource for tracking which entity has keyboard focus. * Methods for getting and setting keyboard focus. * Event definitions for triggering bubble-able keyboard input events to the focused entity. * A system for dispatching keyboard input events to the focused entity. This crate does *not* provide any integration with UI widgets, or provide functions for tab navigation or gamepad-based focus navigation, as those are typically application-specific. ## Testing Most of the code has been copied from a different project, one that has been well tested. However, most of what's in this module consists of type definitions, with relatively small amounts of executable code. That being said, I expect that there will be substantial bikeshedding on the design, and I would prefer to hold off writing tests until after things have settled. I think that an example would be appropriate, however I'm waiting on a few other pending changes to Bevy before doing so. In particular, I can see a simple example with four buttons, with focus navigation between them, and which can be triggered by the keyboard. @alice-i-cecile
		
			
				
	
	
		
			81 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
			
		
		
	
	
			81 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
| # if crate A depends on crate B, B must come before A in this list
 | |
| crates=(
 | |
|     bevy_utils
 | |
|     bevy_ptr
 | |
|     bevy_macro_utils
 | |
|     bevy_derive
 | |
|     bevy_math
 | |
|     bevy_color
 | |
|     bevy_tasks
 | |
|     bevy_reflect/derive
 | |
|     bevy_reflect
 | |
|     bevy_ecs/macros
 | |
|     bevy_ecs
 | |
|     bevy_state/macros
 | |
|     bevy_state
 | |
|     bevy_app
 | |
|     bevy_time
 | |
|     bevy_log
 | |
|     bevy_asset/macros
 | |
|     bevy_asset
 | |
|     bevy_audio
 | |
|     bevy_core
 | |
|     bevy_diagnostic
 | |
|     bevy_hierarchy
 | |
|     bevy_transform
 | |
|     bevy_window
 | |
|     bevy_encase_derive
 | |
|     bevy_render/macros
 | |
|     bevy_mikktspace
 | |
|     bevy_image
 | |
|     bevy_mesh
 | |
|     bevy_render
 | |
|     bevy_core_pipeline
 | |
|     bevy_input
 | |
|     bevy_gilrs
 | |
|     bevy_animation
 | |
|     bevy_pbr
 | |
|     bevy_gltf
 | |
|     bevy_remote
 | |
|     bevy_scene
 | |
|     bevy_picking
 | |
|     bevy_sprite
 | |
|     bevy_gizmos/macros
 | |
|     bevy_gizmos
 | |
|     bevy_text
 | |
|     bevy_a11y
 | |
|     bevy_input_focus
 | |
|     bevy_ui
 | |
|     bevy_winit
 | |
|     bevy_dev_tools
 | |
|     bevy_internal
 | |
|     bevy_dylib
 | |
| )
 | |
| 
 | |
| if [ -n "$(git status --porcelain)" ]; then
 | |
|     echo "You have local changes!"
 | |
|     exit 1
 | |
| fi
 | |
| 
 | |
| pushd crates
 | |
| 
 | |
| for crate in "${crates[@]}"
 | |
| do
 | |
|   echo "Publishing ${crate}"
 | |
|   cp ../LICENSE-MIT "$crate"
 | |
|   cp ../LICENSE-APACHE "$crate"
 | |
|   pushd "$crate"
 | |
|   git add LICENSE-MIT LICENSE-APACHE
 | |
|   cargo publish --no-verify --allow-dirty
 | |
|   popd
 | |
|   sleep 20
 | |
| done
 | |
| 
 | |
| popd
 | |
| 
 | |
| echo "Publishing root crate"
 | |
| cargo publish --allow-dirty
 | |
| 
 | |
| echo "Cleaning local state"
 | |
| git reset HEAD --hard
 |