diff options
author | Xi Yan | 2018-12-10 20:31:41 +0000 |
---|---|---|
committer | Xi Yan | 2018-12-11 14:53:34 +0000 |
commit | fd0ee04a8a4385c7e48a8e257c434a2b7024d753 (patch) | |
tree | 7f79ccbf01273c39c2faa9f7a962fae6d4ecb2be /bundles | |
parent | ff43bbde22e2a1f86e444ae47942a47f17d77b71 (diff) | |
download | eclipse.platform.swt-fd0ee04a8a4385c7e48a8e257c434a2b7024d753.tar.gz eclipse.platform.swt-fd0ee04a8a4385c7e48a8e257c434a2b7024d753.tar.xz eclipse.platform.swt-fd0ee04a8a4385c7e48a8e257c434a2b7024d753.zip |
Bug 542475 - [GTK3] DateTime date decreases when focusing out
Same issue as bug 538648 with the SWT.MEDIUM style on US locale.
Modified previous patch to account for all cases where Month as string
is the first field in DateTime spinner.
When using SWT.SHORT | SWT.DATE on US locale, increment arrow increases
date by 2 and decrement arrow doesn't work. This is because new_value
from calendar have month between 0-11 while the adj_value have month
betwene 1-12. Fix is to shift adj_value by 1 offset so that we get the
correct arrow direction. This doesn't happen if DATE is the first value
(i.e. using Canada locale)
Change-Id: I52c5ef02e936a89d66566032aff437d165ceb289
Signed-off-by: Xi Yan <xixiyan@redhat.com>
Diffstat (limited to 'bundles')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java index 4e583b5d0b..94252f69f7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java @@ -1851,18 +1851,28 @@ void deregister () { } int getArrow(long /*int*/ widget) { + updateControl(); int adj_value = (int) GTK.gtk_adjustment_get_value(GTK.gtk_spin_button_get_adjustment(widget)); int new_value = 0; if (isDate()) { - if ((style & SWT.LONG) != 0) { - if (adj_value == 0) { - return 0; - } else { - return adj_value > 0 ? SWT.ARROW_UP : SWT.ARROW_DOWN; - } - } FieldPosition firstField = getNextField(null); + int firstFieldConstant = getCalendarField(firstField); new_value = calendar.get(getCalendarField(firstField)); + if (firstFieldConstant == Calendar.MONTH) { + if ((style & SWT.SHORT) != 0) { + // adj_value returns the month as a number between 1-12 + // new_value gets the month as a number between 0-11 + // shift the adj_value by offset so that we get the correct arrow direction + adj_value--; + } else if ((style & SWT.MEDIUM) != 0 || (style & SWT.LONG) != 0 ) { + // adj_value is either +1, 0, -1 when month is displayed as string + if (adj_value == 0) { + return 0; + } else { + return adj_value > 0 ? SWT.ARROW_UP : SWT.ARROW_DOWN; + } + } + } } else if (isTime()) { new_value = getHours(); if (hasAmPm()) { |