Skip to content

Commit

Permalink
fix text input and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tasgon committed Mar 5, 2024
1 parent 7173689 commit 073f920
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/fonts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn main() {
.add_plugins(IcedPlugin {
fonts: vec![ALPHAPROTA_FONT_BYTES],
settings: iced::Settings {
default_text_size: 40.0,
default_text_size: 40.0.into(),
default_font: ALPHAPROTA_FONT,
..Default::default()
},
Expand Down
2 changes: 1 addition & 1 deletion examples/toggle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn main() {

fn toggle_system(mut keyboard: EventReader<KeyboardInput>, mut active: ResMut<UiActive>) {
for event in keyboard.read() {
if event.key_code == Some(KeyCode::Space) && event.state == ButtonState::Pressed {
if event.key_code == KeyCode::Space && event.state == ButtonState::Pressed {
active.0 = !active.0;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,13 @@ pub fn process_input(

for ev in events.received_character.read() {
for char in ev.char.chars() {
let smol_str = SmolStr::new(char.to_string());
let event = keyboard::Event::KeyPressed {
key: keyboard::Key::Character(SmolStr::new(char.to_string())),
key: keyboard::Key::Character(smol_str.clone()),
modifiers,
// NOTE: This is a winit thing we don't get from bevy events
location: keyboard::Location::Standard,
text: None,
text: Some(smol_str),
};
event_queue.push(IcedEvent::Keyboard(event));
}
Expand Down

0 comments on commit 073f920

Please sign in to comment.