Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] SWT: TextField ModifyListener

Hello everyone,

quick question:

If I have two text fields and want to clear the text of one when there
is a ModifyEvent on the other one, I do the following:

public class OrderModifyListener implements ModifyListener
{
        MainWindow mainWindow;

        public OrderModifyListener(MainWindow window)
        {
                mainWindow = window;
        }

        public void modifyText(ModifyEvent e)
        {
                if (!(mainWindow.getQualifierField().getText().equals("")))
                {
                        mainWindow.getQualifierField().setText("");
                }
        }

}

The following is happening:

If there is text in the Qualifierfield, it is being cleared, BUT the
character typed in the textfield listening to the event gets lost. All
further typed characters are being entered properly.

To me, this appears as if the keyup event which should insert the
character is being lost when the modify event is being caught.

What am I doing wrong? I could of course just implement a KeyListener
and catch the keyup event, but I am interested as to how this is done
the right way.


Sorry to ask about this on this list, but there appears to be no other place, at least I was unable to find it.

Back to the top