Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ std = ["bevy/std"]
libm = ["bevy/libm"]

[dependencies.bevy]
version = "0.18.0"
version = "0.19.0-rc.1"
default-features = false
features = ["bevy_ui", "bevy_asset", "bevy_text", "bevy_window"]

[dev-dependencies.bevy]
version = "0.18.0"
version = "0.19.0-rc.1"
default-features = true

[lints.rust]
Expand Down
2 changes: 1 addition & 1 deletion examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn setup(mut commands: Commands) {
BackgroundColor(BACKGROUND_COLOR),
TextInput,
TextInputTextFont(TextFont {
font_size: 34.,
font_size: FontSize::Px(34.),
..default()
}),
TextInputTextColor(TextColor(TEXT_COLOR)),
Expand Down
12 changes: 6 additions & 6 deletions examples/focus.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! An example showing a more advanced implementation with focus.

use bevy::{
input_focus::{InputDispatchPlugin, InputFocus},
input_focus::{FocusCause, InputFocus},
prelude::*,
};
use bevy_simple_text_input::{
Expand All @@ -16,7 +16,7 @@ const BACKGROUND_COLOR: Color = Color::srgb(0.15, 0.15, 0.15);

fn main() {
App::new()
.add_plugins((DefaultPlugins, InputDispatchPlugin))
.add_plugins(DefaultPlugins)
.add_plugins(TextInputPlugin)
.add_systems(Startup, setup)
.add_systems(Update, focus.before(TextInputSystem))
Expand Down Expand Up @@ -55,7 +55,7 @@ fn text_input(placeholder_hide_on_focus: bool) -> impl Bundle {
BackgroundColor(BACKGROUND_COLOR),
TextInput,
TextInputTextFont(TextFont {
font_size: 34.,
font_size: FontSize::Px(34.),
..default()
}),
TextInputTextColor(TextColor(TEXT_COLOR)),
Expand All @@ -77,7 +77,7 @@ fn focus(
}

for (entity, mut inactive, mut border_color) in text_inputs.iter_mut() {
if focus.0 == Some(entity) {
if focus.get() == Some(entity) {
inactive.0 = false;
*border_color = BORDER_COLOR_ACTIVE.into();
} else {
Expand All @@ -88,11 +88,11 @@ fn focus(
}

fn background_node_click(mut trigger: On<Pointer<Click>>, mut focus: ResMut<InputFocus>) {
focus.0 = None;
focus.clear();
trigger.propagate(false);
}

fn text_input_click(mut trigger: On<Pointer<Click>>, mut focus: ResMut<InputFocus>) {
focus.0 = Some(trigger.event_target());
focus.set(trigger.event_target(), FocusCause::Pressed);
trigger.propagate(false);
}
2 changes: 1 addition & 1 deletion examples/password.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn setup(mut commands: Commands) {
TextInput,
TextInputValue("password".to_string()),
TextInputTextFont(TextFont {
font_size: 34.,
font_size: FontSize::Px(34.),
..default()
}),
TextInputTextColor(TextColor(TEXT_COLOR)),
Expand Down
2 changes: 1 addition & 1 deletion examples/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn setup(mut commands: Commands) {
commands.spawn(Camera2d);

let text_font = TextFont {
font_size: 40.,
font_size: FontSize::Px(40.),
..default()
};
let text_color = TextColor(TEXT_COLOR);
Expand Down
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Plugin for TextInputPlugin {
app,
CURSOR_HANDLE,
"../assets/Cursor.ttf",
|bytes: &[u8], _path: String| { Font::try_from_bytes(bytes.to_vec()).unwrap() }
|bytes: &[u8], _path: String| { Font::from_bytes(bytes.to_vec(), "Cursor") }
);

app.init_resource::<TextInputNavigationBindings>()
Expand Down Expand Up @@ -534,7 +534,7 @@ fn scroll_with_cursor(
continue;
};

match layout.glyphs.last().map(|g| g.span_index) {
match layout.glyphs.last().map(|g| g.section_index) {
// No text, nothing to do.
None => continue,
// If cursor is at the end, we can use FlexEnd so newly typed text does not take a
Expand All @@ -555,7 +555,7 @@ fn scroll_with_cursor(
let Some(cursor_pos) = layout
.glyphs
.iter()
.find(|g| g.span_index == CURSOR_SPAN)
.find(|g| g.section_index == CURSOR_SPAN)
.map(|p| p.position.x * inverse_scale_factor)
else {
continue;
Expand Down Expand Up @@ -618,7 +618,7 @@ fn create(
let text = commands
.spawn((
Text::default(),
TextLayout::new_with_linebreak(LineBreak::NoWrap),
TextLayout::default().with_linebreak(LineBreak::NoWrap),
Name::new("TextInputInner"),
TextInputInner,
))
Expand All @@ -630,7 +630,7 @@ fn create(
parent.spawn((
TextSpan::new(&values.1),
TextFont {
font: CURSOR_HANDLE,
font: FontSource::Handle(CURSOR_HANDLE),
..font.0.clone()
},
if inactive.0 {
Expand Down Expand Up @@ -660,7 +660,7 @@ fn create(
let placeholder_text = commands
.spawn((
Text::default(),
TextLayout::new_with_linebreak(LineBreak::NoWrap),
TextLayout::default().with_linebreak(LineBreak::NoWrap),
Name::new("TextInputPlaceholderInner"),
TextInputPlaceholderInner,
if placeholder_visible {
Expand All @@ -678,7 +678,7 @@ fn create(
parent.spawn((
TextSpan::new(&values.1),
TextFont {
font: CURSOR_HANDLE,
font: FontSource::Handle(CURSOR_HANDLE),
..font.0.clone()
},
TextColor(Color::NONE),
Expand Down Expand Up @@ -826,7 +826,7 @@ fn update_style(

*writer.font(inner, PRE_CURSOR_SPAN) = font.0.clone();
*writer.font(inner, CURSOR_SPAN) = TextFont {
font: CURSOR_HANDLE,
font: FontSource::Handle(CURSOR_HANDLE),
..font.0.clone()
};
*writer.font(inner, POST_CURSOR_SPAN) = font.0.clone();
Expand Down
Loading