eclipse-platform / eclipse.platform.swt

Eclipse SWT
https://www.eclipse.org/swt/
Eclipse Public License 2.0
112 stars 135 forks source link

Date not selected if user clicks on different month #768

Open MarioMarinatoSTech opened 1 year ago

MarioMarinatoSTech commented 1 year ago

Describe the bug The DateTime widget does not change to correct date when clicked, if the user clicks on a different month on the drop down calendar.

To Reproduce

Instead of changing to the clicked date, the previous one is still set. If one opens the popup again, it will be "scrolled" correctly to the clicked month.

Expected behavior Clicking on a day from a different month should correctly trigger the selection of the date. Or it should behave as macOS does: only scroll the month and not trigger the selection.

Screenshots If applicable, add screenshots to help explain your problem.

Environment:

  1. Select the platform(s) on which the behavior is seen:

      • [ ] All OS
      • [ ] Windows
      • [ ] Linux
      • [x] macOS
  2. Additional OS info (e.g. OS version, Linux Desktop, etc) MacOS Ventura 13.4.1

  3. JRE/JDK version Amazon Corretto JDK 11

Version since Confirmed on Eclipse 2020-12 and 2022-12.

Workaround (or) Additional context none

Phillipus commented 1 year ago

I tried to reproduce the problem on macOS 13.5 (Mac Mini M1), Eclipse 2023-06 and Java 17 but couldn't.

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.DateTime;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class DateTimeTest {

    public static void main(String[] args) {
        final Display display = new Display();

        final Shell shell = new Shell(display);
        shell.setText("Date Time Test");
        shell.setLayout(new GridLayout());

        DateTime dt = new DateTime(shell, SWT.DATE | SWT.DROP_DOWN);

        dt.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
            System.out.println(dt);
        }));

        shell.setSize(200, 100);
        shell.open();

        while(!shell.isDisposed()) {
            if(!display.readAndDispatch()) {
                display.sleep();
            }
        }

        display.dispose();
    }
}
elsazac commented 1 year ago

I have tried the above snippet in MacOS Ventura 13.4.1(Apple M1 Pro) with Java 20 but couldn't reproduce it either. Attaching the build details:

Eclipse SDK Version: 2023-09 (4.29) Build id: I20230815-1800 OS: Mac OS X, v.13.4.1, aarch64 / cocoa Java vendor: Eclipse Adoptium Java runtime version: 20+36 Java version: 20

deepika-u commented 1 year ago

With the snippet shared by Phillipus i have tried below

  1. Try to select Sept 11th => image

  2. Try to select Oct 31st => image

I am able to select that particular date and it gets showed properly on Windows 11.

I am on below environment Eclipse SDK Version: 2023-09 (4.29) Build id: I20230816-0600 OS: Windows 11, v.10.0, x86_64 / win32 Java vendor: Eclipse Adoptium Java runtime version: 20+36 Java version: 20

MarioMarinatoSTech commented 1 year ago

Strange. I tried it again, using @Phillipus' snippet, and the issue still happens.

This time, I did it using Eclipse 2023-06 and Java Temurin 17.0.8+7, on the same Mac as before.

I wonder if there's a Mac setting that might be different on our machines, that could be leading to the difference in behavior.

Phillipus commented 1 year ago

I wonder if there's a Mac setting that might be different on our machines, that could be leading to the difference in behavior.

Localization? Could be some setting there?