Bug? ValueChanged not firing from spinner object

mrred128

Active Member
Licensed User
Longtime User
If the Editable feature of the spinner object is enabled, any direct entries on the object does not fire the event. The up/down selections do with/without the editable feature

B4J 5.80
 

mrred128

Active Member
Licensed User
Longtime User
Hitting enter does trigger the event, but switching focus to another control does not. Data loss is a bad rabbit hole to fall into.
 

mrred128

Active Member
Licensed User
Longtime User
using tab or mouse clicks achieve the same result......no fire The only thing that does work is hitting the enter key.

Either way, it's a help-desk problem waiting to happen. It's forever disabled now.
 

Woinowski

Active Member
Licensed User
Longtime User
This issue is really annoying. In my application, I encounter the issue in a similar way. Basically I have a list view to choose items and spinners for each item's values. With editable = false everything works, with editable = true I have logged the event subs that happen and can basically see the following:

1. I change the value for one item (up/down or direct edit)
2. I click on a new item in my listview (loss of focus for spinner, then the selectedindex changed should fire for listview). What should happen: The old item is saved (last selected index is available), then the value of the new is shown, then the new selected item is show.
what really happens:
3. The spinner's value field is at the value before changing it by the user (e.g. the default 0)
4. So the original, not the changed value is saved to the old item
5. The new value is loaded, and my code in theory should overwrite the value of the spinner
6. Instead, the value entered in step 1. is shown

I tried some workarounds, including extra writing the changed value from the newly selected item. Now the funny thing is: In debug compile mode it works, in release compile mode it does not work.

For me this looks like the events happen out of order, maybe there is some kind of race condition. Because of different execution speeds in release and debug mode, the race condition seems to decide correct in debug and wrong in release.

Fortunately I found this thread and now can set editable to false as workaround. Not my favourite solution, might prefer a text field then...

Maybe you would like to look into this again Erel.

PS. Sorry, cannot disclose the code. Hopefully the description helps to replicate it.
 

Woinowski

Active Member
Licensed User
Longtime User
Hello Erel, here is a small sample project.

How to see the bug with it.

1. Just use the up/down arrows and the button to change between "items" ==> Works as expected
2. Enter a value in the editable field ==> Data loss

Thanks in advance for looking into that.
Jens
 

Attachments

  • SpinnerIssue.zip
    2.2 KB · Views: 257

Woinowski

Active Member
Licensed User
Longtime User
Added even more log points, including for Value Changed Event. Here is the log. User actions and effect on GUI in Square Brackets.

Waiting for debugger to connect...
Program started.
[Enter manually: "15". Display changes. Value change event NOT FIRED]
[Toggle button clicked]
Current item Start: 0
Current value: Start - 0
Current value: #2 - 0
Current value: #3 - 0
Current item end: 1
Current value end - 0
[Display still shows 15]
[Toggle button clicked]
Current item Start: 1
Current value: Start - 0
Current value: #2 - 0
Current value: #3 - 0
Current item end: 0
Current value end - 0
[Display still shows 15]

For me this looks like as if the text field is just decoupled from the Spinner.value. In both directions:
1. Entered number does not change Spinner.value (always)
2. Change Spinner.value does not always change text field
 

Attachments

  • SpinnerIssue.zip
    2.3 KB · Views: 261

Woinowski

Active Member
Licensed User
Longtime User
That's it. Installed JDK 9 and now it works.

Only one minor point: Unlike TextFields, the ValueChange only fires if the Spinner looses the fcous or you press Enter. Textfields already fires Changed Event if you enter letters
 
Top