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

The following examples show how to use org.eclipse.swt.SWT#TRAVERSE_ARROW_NEXT . 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: CTree.java    From nebula with Eclipse Public License 2.0 6 votes vote down vote up
private void handleTraverse(Event event) {
	switch (event.detail) {
	case SWT.TRAVERSE_RETURN:
		if (event.data instanceof CTreeCell) {
			fireSelectionEvent(true);
		}
		break;
	case SWT.TRAVERSE_ARROW_NEXT:
		if(!selection.isEmpty()) {
			setSelection(((CTreeItem) selection.get(selection.size()-1)).nextVisible());
		}
		break;
	case SWT.TRAVERSE_ARROW_PREVIOUS:
		if(!selection.isEmpty()) {
			setSelection(((CTreeItem) selection.get(0)).previousVisible());
		}
		break;
	}
}
 
Example 2
Source File: CSpinner.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Processes up/down key event
 * 
 * @param e
 *            The key event type.
 */
protected void traverse( Event e )
{
	switch ( e.detail )
	{
		case SWT.TRAVERSE_ARROW_PREVIOUS :
			if ( e.keyCode == SWT.ARROW_UP )
			{
				e.doit = true;
				e.detail = SWT.NULL;
				up( );
			}
			break;
		case SWT.TRAVERSE_ARROW_NEXT :
			if ( e.keyCode == SWT.ARROW_DOWN )
			{
				e.doit = true;
				e.detail = SWT.NULL;
				down( );
			}
	}
}
 
Example 3
Source File: SWTNullableSpinner.java    From atdl4j with MIT License 6 votes vote down vote up
void traverse(Event e) {
	switch (e.detail) {
	case SWT.TRAVERSE_ARROW_PREVIOUS:
		if (e.keyCode == SWT.ARROW_UP) {
			e.doit = true;
			e.detail = SWT.NULL;
			up();
		}
		break;

	case SWT.TRAVERSE_ARROW_NEXT:
		if (e.keyCode == SWT.ARROW_DOWN) {
			e.doit = true;
			e.detail = SWT.NULL;
			down();
		}
		break;
	}
}
 
Example 4
Source File: DateChooser.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Manages event at the calendar level.
 *
 * @param event event
 */
protected void calendarEvent(Event event) {
	switch (event.type) {
		case SWT.Traverse:
			switch (event.detail) {
				case SWT.TRAVERSE_ARROW_NEXT:
				case SWT.TRAVERSE_ARROW_PREVIOUS:
				case SWT.TRAVERSE_PAGE_NEXT:
				case SWT.TRAVERSE_PAGE_PREVIOUS:
					event.doit = false;
					break;
				default:
					event.doit = true;
			}
			break;

		case SWT.FocusIn:
			handleFocus(event.type);
			break;

		case SWT.KeyDown: {
			final boolean ctrl = (event.stateMask & SWT.CTRL) != 0;
			switch (event.keyCode) {
				case SWT.ARROW_LEFT:
					if (event.stateMask != 0) {
						return;
					}
					setFocus(focusIndex - 1);
					break;
				case SWT.ARROW_RIGHT:
					if (event.stateMask != 0) {
						return;
					}
					setFocus(focusIndex + 1);
					break;
				case SWT.ARROW_UP:
					if (event.stateMask != 0) {
						return;
					}
					setFocus(focusIndex - 7);
					break;
				case SWT.ARROW_DOWN:
					if (event.stateMask != 0) {
						return;
					}
					setFocus(focusIndex + 7);
					break;
				case SWT.PAGE_DOWN:
					if (event.stateMask != 0 || !navigationEnabled) {
						return;
					}
					changeCurrentMonth(ctrl ? 12 : 1);
					break;
				case SWT.PAGE_UP:
					if (event.stateMask != 0 || !navigationEnabled) {
						return;
					}
					changeCurrentMonth(ctrl ? -12 : -1);
					break;
				case ' ':
					select(focusIndex, event.stateMask);
					break;
				case SWT.HOME:
					if (event.stateMask != 0) {
						return;
					}
					setFocusOnToday(autoSelectOnFooter);
					break;
				default:
					return;
			}
			if (hasFocus) {
				gridRedraw();
			}
			break;
		}

		case SWT.Dispose: {
			final Display display = getDisplay();
			display.removeFilter(SWT.FocusIn, filter);
			display.removeFilter(SWT.KeyDown, filter);
			hasFocus = false;
			break;
		}
	}
}
 
Example 5
Source File: CDateTime.java    From nebula with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * The Travers event handler. Note that ARROW_UP and ARROW_DOWN are handled
 * in the <code>handleKey</code> method.
 * 
 * @param event
 *            the event
 */
void handleTraverse(Event event) {
	boolean allowTimeZoneEdit = this.allowedTimezones != null;

	switch (event.detail) {
	case SWT.TRAVERSE_ARROW_NEXT:
		if (event.keyCode == SWT.ARROW_RIGHT) {
			fieldNext();
		} else if (event.keyCode == SWT.ARROW_DOWN) {
			fieldAdjust(-1);
		}
		break;
	case SWT.TRAVERSE_ARROW_PREVIOUS:
		if (event.keyCode == SWT.ARROW_LEFT) {
			fieldPrev();
		} else if (event.keyCode == SWT.ARROW_UP) {
			fieldAdjust(1);
		}
		break;
	case SWT.CR:
		fieldNext();
		fireSelectionChanged();
		break;
	case SWT.TRAVERSE_TAB_NEXT:
		if (tabStops && hasSelection()) {
			// if we are at the last field, allow the tab out of the control
			// the last field is also considered to be the 2nd to last if
			// the last is a time zone
			// we now check if the control allows time zone editing
			if (activeField == field.length - 1
					|| activeField == field.length - 2
							&& Calendar.ZONE_OFFSET == getCalendarField(
									field[field.length - 1])
							&& !allowTimeZoneEdit) {
				event.doit = true;
			} else {
				event.doit = false;
				if (activeField < 0) {
					fieldPrev();
				} else {
					fieldNext();
				}
			}
		}
		break;
	case SWT.TRAVERSE_TAB_PREVIOUS:
		if (tabStops && hasSelection()) {
			// if we are at the 1st field, allow the tab out of the control
			// the 1st field is also considered to the the 2nd if the 1st
			// is a time zone
			if (activeField == 0 || activeField == 1
					&& Calendar.ZONE_OFFSET == getCalendarField(field[0])
					&& !allowTimeZoneEdit) {
				event.doit = true;
			} else {
				event.doit = false;
				if (activeField < 0) {
					fieldNext();
				} else {
					fieldPrev();
				}
			}
		}
		break;
	default:
	}
}
 
Example 6
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 7
Source File: MarkerEditorComposite.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void canvasEvent( Event event )
{
	switch ( event.type )
	{
		case SWT.FocusIn :
		{
			cnvMarker.redraw( );
			break;
		}
		case SWT.FocusOut :
		{
			cnvMarker.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_DOWN
					|| event.keyCode == SWT.CR
					|| event.keyCode == SWT.KEYPAD_CR )
			{
				event.doit = true;
				toggleDropDown( );
			}
			break;
		}
		case SWT.Traverse :
		{
			switch ( event.detail )
			{
				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;
					cnvMarker.redraw( );
			}

			break;
		}
		case SWT.Paint :
			paintMarker( event.gc, getMarker( ), LocationImpl.create( 10,
					10 ) );
			break;
	}
}
 
Example 8
Source File: LineSeriesMarkerSheet.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
void handleEventCanvasMarkers( Event event )
{
	switch ( event.type )
	{
		case SWT.KeyDown :
		{
			if ( event.keyCode == SWT.ARROW_LEFT )
			{
				if ( iSelectedIndex - 1 >= 0 )
				{
					iSelectedIndex--;
					setEnabledState( );
				}
			}
			else if ( event.keyCode == SWT.ARROW_RIGHT )
			{
				if ( iSelectedIndex + 1 < getMarkers( ).size( ) )
				{
					iSelectedIndex++;
					setEnabledState( );
				}
			}
			else if ( event.keyCode == SWT.ARROW_UP )
			{
				if ( iSelectedIndex - MARKER_ROW_MAX_NUMBER >= 0 )
				{
					iSelectedIndex -= MARKER_ROW_MAX_NUMBER;
					setEnabledState( );
				}
			}
			else if ( event.keyCode == SWT.ARROW_DOWN )
			{
				if ( iSelectedIndex + MARKER_ROW_MAX_NUMBER < getMarkers( ).size( ) )
				{
					iSelectedIndex += MARKER_ROW_MAX_NUMBER;
					setEnabledState( );
				}
			}
			
			else if ( event.keyCode == SWT.CR
					|| event.keyCode == SWT.KEYPAD_CR )
			{
				currentMarkerEditor.setFocus( );
			}
			else if ( event.keyCode == SWT.ESC )
			{
				cnvMarkers.getShell( ).close( );
			}
			break;
		}
		case SWT.Traverse :
		{
			switch ( event.detail )
			{
				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;
					cnvMarkers.redraw( );
			}
			break;
		}
		case SWT.Paint :
			paintControl( new PaintEvent( event ) );
			break;
		case SWT.MouseDown :
			mouseDown( new MouseEvent( event ) );
			break;
	}
}
 
Example 9
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;
	}
}