1 11 12 package org.eclipse.ui.internal.keys; 13 14 import org.eclipse.swt.SWT; 15 import org.eclipse.swt.custom.StyledText; 16 import org.eclipse.swt.custom.VerifyKeyListener; 17 import org.eclipse.swt.events.VerifyEvent; 18 import org.eclipse.swt.widgets.Widget; 19 20 26 class OutOfOrderVerifyListener implements VerifyKeyListener { 27 28 34 private int active = Integer.MIN_VALUE; 35 36 40 private OutOfOrderListener chainedListener; 41 42 50 OutOfOrderVerifyListener(OutOfOrderListener outOfOrderListener) { 51 chainedListener = outOfOrderListener; 52 } 53 54 64 final boolean isActive(final int timeRegistered) { 65 return (active == timeRegistered); 66 } 67 68 78 final void setActive(final int timeRegistered) { 79 active = timeRegistered; 80 } 81 82 90 public void verifyKey(VerifyEvent event) { 91 final Widget widget = event.widget; 93 if ((widget instanceof StyledText) && (!widget.isDisposed())) { 94 ((StyledText) widget).removeVerifyKeyListener(this); 95 } 96 97 101 if (event.doit) { 102 widget.addListener(SWT.Modify, new CancelOnModifyListener( 103 chainedListener)); 104 widget.addListener(SWT.KeyDown, chainedListener); 105 } 106 } 107 } 108 | Popular Tags |