Bug 202982

Summary: Possibility to add a VerifyListener to DateTime widget.
Product: [Eclipse Project] Platform Reporter: Pieter Agten <spam.pieter>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: a_ilyin, ben.rowlands, daniel.kruegler, eclipse.felipe, steve_northover, tom.schindl
Version: 3.3   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Pieter Agten CLA 2007-09-11 14:54:05 EDT
I would be nice if it would be possible to add a VerifyListener to the DateTime control in SWT.

I tried to invalidate the user's selection of a date when it was after the date of another DateTime widget and then leave the widget back with the date it originally had.

I tried to do this using a SelectionListener and the 'e.doit' property, but that doesn't seem to work.

This code illustrates what I was trying to do:

dateTimeStart.addSelectionListener(new SelectionListener() {

  @Override
  public void widgetDefaultSelected(SelectionEvent e) {
  }

  @Override
  public void widgetSelected(SelectionEvent e) {
    if (dateIsBeforeOtherDate())
       //The date is NOT valid. The user's input should be invalidated.
       e.doit = false;
    else
       /The date is valid. The user's input should be copied to the corresponding property in the data model.
       setNewDateInModel();
    }
 });

This code doesn't work. Eventhough e.doit is set to false, the input of the DateTime widget still changes.

The solution would be to add a VerifyListener to the DateTime control, but this is currently not possible.
Comment 1 Alexander Ilyin CLA 2008-02-23 08:27:22 EST
Also please add SWT.Modify event (to have a chance share common listeners with Text controls). 
And requested SWT.Verify event is absolutely needed to make things like setting the min/max limits for date/time. 
Comment 2 Lars Vogel CLA 2019-09-24 13:58:09 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.