Java Code Examples for org.eclipse.swt.SWT#TRAVERSE_ESCAPE

The following examples show how to use org.eclipse.swt.SWT#TRAVERSE_ESCAPE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DateChooserComboCellEditor.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
protected Control createControl(Composite parent) {
	combo = new DateChooserCombo(parent, getStyle());
	combo.setFont(parent.getFont());

	Listener listener = new Listener() {
		public void handleEvent(Event event) {
			switch ( event.type ) {
				case SWT.Traverse :
					if ( event.detail == SWT.TRAVERSE_ESCAPE
							 || event.detail == SWT.TRAVERSE_RETURN ) {
						event.doit = false;
					}
					break;

				case SWT.FocusOut :
					DateChooserComboCellEditor.this.focusLost();
					break;
			}				
		}
	};
	combo.addListener(SWT.Traverse, listener);
	combo.addListener(SWT.FocusOut, listener);

	return combo;
}
 
Example 2
Source File: TableCellEditorListener.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void handleEvent(final Event e) {
    if (e.type == SWT.FocusOut) {
        tableItem.setText(text.getText());
        text.dispose();
        table.setFocus();
    } else if (e.type == SWT.Traverse) {
        if (e.detail == SWT.TRAVERSE_RETURN) {
            tableItem.setText(text.getText());
            e.doit = true;
        }
        if (e.detail == SWT.TRAVERSE_RETURN || e.detail == SWT.TRAVERSE_ESCAPE) {
            text.dispose();
            if (e.detail == SWT.TRAVERSE_ESCAPE) {
                e.doit = false;
            }
        }
    }
}
 
Example 3
Source File: XViewerEditAdapter.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
boolean handleEditEvent(Event event) {
   if (klickedColumn == null || klickedCell == null) {
      return false;
   }

   final Control c;
   try {
      XViewerColumn xColumn =
         xv.getXViewerFactory().getDefaultXViewerColumn(((XViewerColumn) klickedColumn.getData()).getId());
      if (xColumn instanceof ExtendedViewerColumn) {
         ExtendedViewerColumn extendedColumn = (ExtendedViewerColumn) xColumn;
         CellEditDescriptor ced = extendedColumn.getCellEditDescriptorMap().get(klickedCell.getElement().getClass());
         if (ced != null) {
            if (ced.getControl() == null) {
               return false;
            }
            if (ced.getAction() != null && !ced.getAction().isEnabled()) {
               return false;
            }
            if (!converter.isValid(ced, klickedCell.getElement())) {
               return false;
            }
            c = factory.createControl(ced, xv);
            if (c == null) {
               return false;
            }
         } else {
            return false;
         }
      } else {
         return false;
      }

      if (((TreeItem) event.item) != null) {
         Listener myListener = e-> {
               switch (e.type) {
                  case SWT.FocusOut:
                     // set new value
                     getInput(c);
                     c.dispose();
                     break;
                  case SWT.Verify:
                     c.setBounds(klickedCell.getBounds());
                     break;
                  case SWT.Traverse:
                     boolean neighbor = false;
                     switch (e.detail) {
                        case SWT.TRAVERSE_RETURN:
                           // set new value
                           getInput(c);
                           //$FALL-THROUGH$
                        case SWT.TRAVERSE_ESCAPE:
                           c.dispose();
                           e.doit = false;
                           break;
                        case SWT.TRAVERSE_TAB_NEXT:
                           getInput(c);
                           neighbor = getNeighbor(ViewerCell.RIGHT, true);
                           e.doit = false;
                           c.dispose();
                           Event eN = new Event();
                           eN.type = SWT.Selection;
                           eN.widget = xv.getTree();
                           if (neighbor) {
                              eN.item = klickedCell.getItem();
                           }
                           doHandleEvent(eN);
                           break;
                        case SWT.TRAVERSE_TAB_PREVIOUS:
                           getInput(c);
                           neighbor = getNeighbor(ViewerCell.LEFT, true);
                           e.doit = false;
                           c.dispose();
                           Event eP = new Event();
                           eP.type = SWT.Selection;
                           eP.widget = xv.getTree();
                           if (neighbor) {
                              eP.item = klickedCell.getItem();
                           }
                           doHandleEvent(eP);
                           break;
                     }
               }
         };
         c.addListener(SWT.FocusOut, myListener);
         c.addListener(SWT.Traverse, myListener);
         c.addListener(SWT.Verify, myListener);
         // set old value
         setInput(c);
         c.setFocus();
         return true;
      }
   } catch (Exception ex) {
      return false;
   }
   return false;
}
 
Example 4
Source File: FillChooserComposite.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
void handleEventCanvas( Event event )
{
	switch ( event.type )
	{
		case SWT.FocusIn :
		{
			cnvSelection.redraw( );
			break;
		}
		case SWT.FocusOut :
		{
			cnvSelection.redraw( );
			break;
		}
		case SWT.KeyDown :
		{
			if ( event.keyCode == SWT.KEYPAD_CR
					|| event.keyCode == SWT.CR
					|| event.keyCode == ' ' )
			{
				event.doit = true;
				toggleDropDown( );
			}
			break;
		}
		case SWT.MouseDown :
			if ( !bEnabled )
			{
				return;
			}
			// fireHandleEvent( MOUSE_CLICKED_EVENT );
			toggleDropDown( );
			break;
		case SWT.Traverse :
		{
			switch ( event.detail )
			{
				case SWT.TRAVERSE_ESCAPE :
					getShell( ).close( );
					break;
				case SWT.TRAVERSE_RETURN :
				case SWT.TRAVERSE_TAB_NEXT :
				case SWT.TRAVERSE_TAB_PREVIOUS :
				case SWT.TRAVERSE_ARROW_PREVIOUS :
				case SWT.TRAVERSE_ARROW_NEXT :
					event.doit = true;
					cnvSelection.redraw( );
			}
			break;
		}
	}
}
 
Example 5
Source File: CustomChooserComposite.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
void handleEventCanvasSelection( Event event )
{
	switch ( event.type )
	{
		case SWT.FocusIn :
		{
			cnvSelection.redraw( );
			break;
		}
		case SWT.FocusOut :
		{
			cnvSelection.redraw( );
			break;
		}
		case SWT.KeyDown :
		{
			// At this point the widget may have been disposed.
			// If so, do not continue.
			if ( isDisposed( ) )
				break;

			if ( event.keyCode == SWT.ARROW_UP
					|| event.keyCode == SWT.ARROW_DOWN )
			{
				toggleDropDown( );
			}
			break;
		}
		case SWT.Traverse :
		{
			switch ( event.detail )
			{
				case SWT.TRAVERSE_ESCAPE :
					getShell( ).close( );
					break;
				case SWT.TRAVERSE_RETURN :
				case SWT.TRAVERSE_TAB_NEXT :
				case SWT.TRAVERSE_TAB_PREVIOUS :
				case SWT.TRAVERSE_ARROW_PREVIOUS :
				case SWT.TRAVERSE_ARROW_NEXT :
					event.doit = true;
					cnvSelection.redraw( );
			}
			break;
		}
		case SWT.MouseDown :
			toggleDropDown( );
			break;
	}
}