strong & weak widgets

This commit is contained in:
2025-12-11 07:16:06 -05:00
parent a85e129026
commit 36668c82f4
19 changed files with 293 additions and 294 deletions

View File

@@ -30,7 +30,7 @@ pub struct DefaultState<AppState> {
pub struct UiState {
pub renderer: UiRenderer,
pub input: Input,
pub focus: Option<WidgetHandle<TextEdit>>,
pub focus: Option<WidgetView<TextEdit>>,
pub clipboard: Clipboard,
pub window: Arc<Window>,
pub ime: usize,
@@ -91,7 +91,7 @@ impl<State: DefaultAppState> AppState for DefaultState<State> {
let input_changed = ui_state.input.event(&event);
let cursor_state = ui_state.cursor_state().clone();
let old = ui_state.focus.clone();
let old = ui_state.focus;
if cursor_state.buttons.left.is_start() {
ui_state.focus = None;
}
@@ -121,10 +121,9 @@ impl<State: DefaultAppState> AppState for DefaultState<State> {
ui_state.renderer.resize(size)
}
WindowEvent::KeyboardInput { event, .. } => {
if let Some(sel) = &ui_state.focus
if let Some(sel) = ui_state.focus
&& event.state.is_pressed()
{
let sel = &sel.clone();
let mut text = sel.edit(ui);
match text.apply_event(event, &ui_state.input.modifiers) {
TextInputResult::Unfocus => {