Package org.eclipse.swt.events

Examples of org.eclipse.swt.events.KeyListener


     * this is a workaround for the quickdiff assertion if nothing was changed, how to do this
     * better ? is this the right way ?
     */
    showChangeInformation(false);

    getSourceViewer().getTextWidget().addKeyListener(new KeyListener() {
      public void keyPressed(KeyEvent e) {
        int newCaretOffset = getSourceViewer().getTextWidget().getCaretOffset();

        if (newCaretOffset != mCursorPosition) {
          mCursorPosition = newCaretOffset;
View Full Code Here


    private boolean mIsActive;

    private AnnotationFS mCandidate;

    FeatureStructureDragListener(final StyledText textWidget) {
      textWidget.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent e) {
          if (e.keyCode == SWT.ALT) {
            mIsActive = true;

            textWidget.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_HAND));
View Full Code Here

    typeTree.getControl().setLayoutData(
            new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL));

    typeTree.getControl().setFocus();

    filterText.addKeyListener(new KeyListener() {

      public void keyPressed(KeyEvent e) {
        if (e.keyCode == SWT.ARROW_DOWN || e.keyCode == SWT.ARROW_UP) {
          typeTree.getControl().setFocus();

          Tree tree = (Tree) typeTree.getControl();

          if (tree.getItemCount() > 0) {

            tree.setSelection(tree.getItem(0));
          }
        }
      }

      public void keyReleased(KeyEvent e) {
        typeTree.refresh(false);
      }
    });

    typeTree.setContentProvider(new ITreeContentProvider() {

      public Object[] getChildren(Object parentElement) {
        return null;
      }

      public Object getParent(Object element) {
        return null;
      }

      public boolean hasChildren(Object element) {
        return false;
      }

      public Object[] getElements(Object inputElement) {
        return (Type[]) inputElement;
      }

      public void dispose() {
      }

      public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
      }
    });

    typeTree.setFilters(new ViewerFilter[] { new ViewerFilter() {
      @Override
      public boolean select(Viewer viewer, Object parentElement, Object element) {

        // check if the string from the filterText is contained in the type name
        Type type = (Type) element;

        return type.getName().contains(filterText.getText());
      }
    } });

    typeTree.setLabelProvider(new ILabelProvider() {

      public Image getImage(Object element) {
        return null;
      }

      public String getText(Object element) {

        Type type = (Type) element;

        Character key = typeShortcutMap.get(type);

        if (typeShortcutMap != null) {
          return "[" + key + "] " + type.getShortName();
        } else {
          return type.getShortName();
        }
      }

      public void addListener(ILabelProviderListener listener) {

      }

      public void dispose() {
      }

      public boolean isLabelProperty(Object element, String property) {
        return false;
      }

      public void removeListener(ILabelProviderListener listener) {
      }
    });

    typeTree.getControl().addKeyListener(new KeyListener() {

      public void keyPressed(KeyEvent e) {
        Type type = shortcutTypeMap.get(Character.toLowerCase(e.character));

        if (type != null) {
View Full Code Here

    private boolean mIsActive;

    private AnnotationFS mCandidate;

    FeatureStructureDragListener(final StyledText textWidget) {
      textWidget.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent e) {
          if (e.keyCode == SWT.ALT) {
            mIsActive = true;

            textWidget.setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_HAND));
View Full Code Here

    //
    // Until this can be used we improvise by registering a couple of listeners which
    // compute a caret offset change based on events which could change it,
    // that are key and mouse listeners.
   
    getSourceViewer().getTextWidget().addKeyListener(new KeyListener() {
      public void keyPressed(KeyEvent e) {
        int newCaretOffset = getSourceViewer().getTextWidget().getCaretOffset();

        if (newCaretOffset != mCursorPosition) {
          mCursorPosition = newCaretOffset;
View Full Code Here

    // especially on a Mac
    FontData [] fontData = cc.getFont().getFontData();
    ((GridData) cc.getLayoutData()).heightHint = 2 * fontData[0].getHeight();
    cc.addListener(SWT.Selection, this);
    cc.setToolTipText(tip);
    cc.addKeyListener(new KeyListener() {
      private final StringBuffer b = new StringBuffer();

      public void keyPressed(KeyEvent e) {
      }

View Full Code Here

            public void proposalPopupClosed(
                ContentProposalAdapter contentProposalAdapter) {
              // flg[0] = false;
            }
          });
      kindsText.getControl().addKeyListener(new KeyListener() {

        public void keyReleased(KeyEvent e) {

        }
View Full Code Here

    GridData data= new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalAlignment= GridData.FILL;
    data.verticalAlignment= GridData.CENTER;
    fFilterText.setLayoutData(data);
    fFilterText.addKeyListener(new KeyListener() {
      public void keyPressed(KeyEvent e) {
        if (e.keyCode == 0x0D) // return
          gotoSelectedElement();
        if (e.keyCode == SWT.ARROW_DOWN)
          fTreeViewer.getTree().setFocus();
View Full Code Here

    return ((IStructuredSelection) fTreeViewer.getSelection()).getFirstElement();
  }

  private void addListeners(final Tree tree) {
    tree.addKeyListener(new KeyListener() {
      public void keyPressed(KeyEvent e)  {
        if (e.character == 0x1B) // ESC
          dispose();
      }
      public void keyReleased(KeyEvent e) {
View Full Code Here

  public String getText() {
    return fInput;
  }

  private KeyListener getTextKeyListener() {
    return new KeyListener() {
      public void keyPressed(KeyEvent e) {
        if (e.widget instanceof StyledText) {
          int x = ((StyledText) e.widget).getCaretOffset();
          selectColorAtOffset(x);
        }
View Full Code Here

TOP

Related Classes of org.eclipse.swt.events.KeyListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.