Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with a custom widget that wraps a TextInput #2319

Closed
2 tasks done
mtkennerly opened this issue Mar 10, 2024 · 2 comments
Closed
2 tasks done

Problem with a custom widget that wraps a TextInput #2319

mtkennerly opened this issue Mar 10, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@mtkennerly
Copy link
Contributor

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

@mtkennerly mtkennerly added the bug Something isn't working label Mar 10, 2024
@hecrj
Copy link
Member

hecrj commented Mar 10, 2024

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

@mtkennerly
Copy link
Contributor Author

Thanks! That works perfectly :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants