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

[Win32] For a Text field with SWT.Verify-listener the Shift+Del shortcut does not work any more #1468

Open
tmssngr opened this issue Sep 13, 2024 · 5 comments
Labels
bug Something isn't working regression Something that used to work Windows Happens on Windows OS

Comments

@tmssngr
Copy link
Contributor

tmssngr commented Sep 13, 2024

Describe the bug
Normally, the legacy shortcut Shift+Del cuts text in a text field on Windows. This works fine by default until you add a SWT.Verify listener to the Text control.

To Reproduce
Run this snippet:

import org.eclipse.swt.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

public class TextTest {

	public static void main(String[] args) {
		final Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setLayout(new GridLayout(1, false));
		final Text text = new Text(shell, SWT.SINGLE | SWT.BORDER);
		text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
		text.setText("Hello World");
		text.setSelection(6, text.getCharCount());
/*
		text.addListener(SWT.Verify, event -> {
			System.out.println("verify called");
		});
*/

		shell.setSize(400, 100);
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		display.dispose();
	}
}

on Windows and press Shift+Del. "World" will be cut. Now uncomment the SWT.Verify listener and run again. Now Shift+Del does not cut any more.

Expected behavior
Shift+Del should work regardless of the SWT.Verify listener.

Environment:

  1. Select the platform(s) on which the behavior is seen:
    • All OS
    • Windows
    • Linux
    • macOS
  1. Additional OS info (e.g. OS version, Linux Desktop, etc)
    Tried on Windows 11.
@Phillipus
Copy link
Contributor

Phillipus commented Sep 13, 2024

And not just when a verify listener is added to the Text control. It can happen when a Text control is in a wizard or dialog. For example, the Text fields in Eclipse's Preferences pages.

Edit - I was mistaken. Ignore above.

@jukzi jukzi added bug Something isn't working regression Something that used to work Windows Happens on Windows OS labels Sep 13, 2024
@jukzi
Copy link
Contributor

jukzi commented Sep 13, 2024

Does not happen in RCP when there is a custom Command for that key binding (default):
image
reproducable in Large File Associations preferences:
image

@tmssngr
Copy link
Contributor Author

tmssngr commented Sep 14, 2024

@jukzi Do these text fields contain an SWT.Verify listener?

@jukzi
Copy link
Contributor

jukzi commented Sep 14, 2024

yes

@jukzi
Copy link
Contributor

jukzi commented Sep 14, 2024

(to only allow numeric chars)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression Something that used to work Windows Happens on Windows OS
Projects
None yet
Development

No branches or pull requests

3 participants