Bug 558014 - [GTK] Spinner cursor is wrongly positioned for floating point values
Summary: [GTK] Spinner cursor is wrongly positioned for floating point values
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.14   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2019-12-09 03:55 EST by Khanh Hoang CLA
Modified: 2020-09-10 15:49 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Khanh Hoang CLA 2019-12-09 03:55:01 EST
Precondition: setIncrement(25), setDigits(2), setTextLimit(5), setSelection(1075) that means the GUI value is 10,75.
Steps to reproduce:
Case 1:
- put the cursor position at the end of the Spinner.
- press Backspace to delete the last digit.
Result: the value on GUI becomes 10,70 and the cursor jumps to the beginning of the Spinner.
Expected: the value should be 10,7 and the cursor should be at the end.

Case 2:
- delete 2 last digits.
- input one new value after the comma, for example: 2.
Result: the value on GUI becomes 10,20 and the cursor is positioned between 2 and 0.
Expected: the value on GUI should be 10,2 without inserting 0 after it.
Notes: only happens on Linux.
Comment 1 Eric Williams CLA 2019-12-09 09:27:22 EST
Can you provide an SWT snippet that demonstrates the issue?
Comment 2 Khanh Hoang CLA 2019-12-09 23:54:48 EST
(In reply to Eric Williams from comment #1)
> Can you provide an SWT snippet that demonstrates the issue?

Hi Eric,

Please find below the SWT snippet for Spinner that I am using:

final int maximumVal = 6350;
Spinner spin = new Spinner(parentComposite, SWT.BORDER);
spin.setIncrement(25);
spin.setDigits(2);
spin.setMinimum(0);
spin.setMaximum(maximumVal);
spin.setTextLimit(5);
GridData layout = new GridData(SWT.NONE, SWT.NONE, false, false, 1, 1);
layout.minimumWidth = 50;
spin.setLayoutData(powerLayout);
Comment 3 Thang Nguyen CLA 2020-07-20 02:34:41 EDT
Eric, Do we have any updates on this?
Comment 4 Alexander Kurtakov CLA 2020-07-20 03:01:24 EDT
Eric no longer works on Eclipse.
Comment 5 Soraphol (Paul) Damrongpiriyapong CLA 2020-09-08 14:12:53 EDT
Hello, I have taken a look at this. It looks like the cause is in gtk_changed, where we force an update to the spin button through gtk_spin_button_update, which causes the cursor movement and the addition of the zero. 

So the fix is to not have this call to the force update, however, I am not sure of the repercussions. I'm thinking the forced update is used to make sure the SWT.Modify event has the most updated value (?). If that is not the case, removing the gtk_spin_button_update is the fix.

Wondering if anyone has some feedback on why we need to manually update the spin button.
Comment 6 Soraphol (Paul) Damrongpiriyapong CLA 2020-09-08 14:24:24 EDT
Although when the digits of the spin buttons are set to 0, no floating point, the cursor is misplaced. But I believe it is still connected to the manual update on spin button.
Comment 7 Eclipse Genie CLA 2020-09-09 10:52:49 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/169090
Comment 8 Soraphol (Paul) Damrongpiriyapong CLA 2020-09-10 15:49:24 EDT
Hello, I was wondering if you could test on Windows (or whatever platform you use) the behavior for the two cases mentioned in the first comment. I wanted to verify that the change I make is consistent on other platforms. Thanks in advance!