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

SpinBox: value property sometimes fails to propagate to internal TextInput #3053

Open
nununoisy opened this issue Jul 5, 2023 · 5 comments
Labels
a:widgets Implementation of widgets (from std-widgets.slint) and their styles (mF,bS) bug Something isn't working

Comments

@nununoisy
Copy link
Contributor

When binding a SpinBox's value to a property, then updating the property from outside of the SpinBox, the internal TextInput's value is not updated in certain circumstances. I've experimented with the issue a bunch and I believe that the issue manifests when the value is updated from within the SpinBox, though I'm unsure if there are any other triggers.

Here are the steps I've found to reproduce the issue (you can follow along with this SlintPad MRE):

  1. Create a SpinBox with a binding to an integer property and some way for that property to be updated, either from another component or from native code.
  2. Try updating the value externally (click one of the 3 buttons on the MRE) and notice that the value changes as expected.
  3. Update the value using the SpinBox, either by editing the text input or by clicking one of the stepper buttons.
  4. Try updating the value externally and notice that the value no longer updates.
  5. Click a stepper button and notice that the SpinBox acts as though its value is what it had been externally updated to. This shows that the value within the SpinBox is indeed changing, but the TextInput is not receiving the new value.

I can reproduce this on the Qt backend (Qt 6, rust MSVC 1.70 stable, Windows 10 22H2 & Qt 5, rust GNU 1.70 stable, Debian 11 on WSL2) and the web backend (SlintPad).

Looking through the implementation for the Fluent-styled SpinBox, it seems that the issue stems from the way that the TextInput's text prop is updated. Whenever the value is updated from within the SpinBox, update-text() is called to update the TextInput to match. However, when this is done, it seems as though some link between root.value and i-text-input.text is removed; perhaps i-text-input.text is set to a constant equivalent to whatever root.value was at the time?

I unfortunately don't know enough about Slint to suggest a good fix for this. My instinct would be to publicize the update-value(int) function but it would be rather weird for one singular standard component to require value updates to be performed through a function.

@ogoffart ogoffart added bug Something isn't working a:widgets Implementation of widgets (from std-widgets.slint) and their styles (mF,bS) labels Jul 6, 2023
@FloVanGH
Copy link
Member

I have a fix for this issue but from my perspective it make sense to merge #3096 first.

@FloVanGH
Copy link
Member

PR #3101 should fixes the issue for material and fluent SpinBox. For the native SpinBox more work needs to been done, because it lacks an TextInput element in the moment. That will be done next.

@qarmin
Copy link

qarmin commented Nov 26, 2023

I still can reproduce problem with fluent spinbox - code

simplescreenrecorder-2023-11-26_09.43.54.mp4

@FloVanGH
Copy link
Member

needs #112

@JuliDi
Copy link

JuliDi commented Mar 21, 2024

Is there any workaround for forcing an update on the UI until #112 is implemented? I would like to have a "Reset" button for a SpinBox, but the number in the SpinBox is not updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:widgets Implementation of widgets (from std-widgets.slint) and their styles (mF,bS) bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants