iced-rs/iced

Problem with a custom widget that wraps a `TextInput`

mtkennerly opened this issue · 2 comments

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

  • My hardware is compatible and my graphics drivers are up-to-date.

What happened?

I just ran into this while upgrading from 0.10.0 to 0.12.1. I think this is related to #2318, but I have some additional symptoms that may be related to the wrapper widget.

I have a custom widget used for wrapping TextInputs. All of the Widget functions forward to the wrapped widget, except that on_event adds some hooks for ctrl+z/etc.

On 0.12.1, I see these issues:

  • The initial text ("!") is not shown on app startup.
  • The text is shifted down so that you mostly can't see it.
  • The visible text doesn't change after an undo/redo event, even after multiple. The visible text only changes after an input event.

Gist: https://gist.github.com/mtkennerly/edea51b6c35b1cb85421107070cc7569

mintty_LDV0dAOKcW.mp4

What is the expected behavior?

  • Text is fully visible
  • Initial text is visible immediately on startup
  • Visible text changes immediately after undo/redo event

Version

crates.io release

Operating System

Windows

Do you have any log output?

No response

It seems your widget is "state-transparent" but it's including the content state in both Widget::state and Widget::children. Then, you call layout directly with tree, but call the other methods with tree.children[0].

The fix is to remove the children implementation and directly use tree everywhere: https://gist.github.com/hecrj/a7c538d9d0ee37f90a77715f06bb095b/revisions

Thanks! That works perfectly :)