Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Text control + VerifyListener => Undo broken?
Text control + VerifyListener => Undo broken? [message #813578] Mon, 05 March 2012 13:06
Lorenz Wiest is currently offline Lorenz WiestFriend
Messages: 1
Registered: March 2012
Junior Member
I'm running Eclipse Indigo 3.7.1 on Windows 7 and use an SWT Text control with a VerifyListener to uppercase any entered text. Undo (CTRL-Z) appears to work incorrectly with entered text. Could this be a bug, am I using the VerifyListener wrongly, or did I overlook something while attempting to uppercase text with Undo working?

How to reproduce the behavior (sample code below):

1) Enter "HelloWorld" => Text displays as "HELLOWORLD"
2) Move cursor to the start of "HELLOWORLD"
3) Enter "XXX" => Text displays as "XXXHELLOWORLD"
4) Type CTRL-Z (Undo) => Text displays as "HELLOWORLD"
5) Type CTRL-Z (Undo) => Text displays as "XXXHELLOWORLD"
6) Type CTRL-Z (Undo) => Text displays as "HELLOWORLD"
7) Move cursor to the start of "HELLOWORLD"
8) Enter "aaa" => Text displays as "AAAHELLOWORLD"
9) Type CTRL-Z (Undo) => Text remains unchanged (should change to "HELLOWORLD")

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class TextExample_UndoBug {

  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setBounds(100, 100, 200, 100);
    shell.setLayout(new FillLayout());

    final Text text = new Text(shell, SWT.SINGLE);
    text.addVerifyListener(new VerifyListener() {
      public void verifyText(VerifyEvent e) {
        e.text = e.text.toUpperCase();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
Previous Topic:Tree with Multiple Columns - Renderer
Next Topic:Layout Problems
Goto Forum:

Current Time: Sat May 26 02:32:35 GMT 2018

Powered by FUDForum. Page generated in 0.01692 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top