Package org.eclipse.swt.events

Examples of org.eclipse.swt.events.KeyListener


    //
    // 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


    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

    // 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

    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 (key != 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

        filterText = new Text(composite, SWT.SEARCH | SWT.SINGLE);
        filterText.setLayoutData("growx,wrap");
        filterText.setText(TYPE_FILTER_TEXT);
        filterText.setSelection(0, filterText.getCharCount());
        filterText.addKeyListener(new KeyListener(){
            public void keyReleased( KeyEvent e ) {
                viewer.refresh();
            }
            public void keyPressed( KeyEvent e ) {
            }
View Full Code Here

          }
        }
        item.setText(1, newText);
      }
    });
    editorColumnX.addKeyListener(new KeyListener() {

      public void keyReleased(KeyEvent e) {
        // not used
      }
View Full Code Here

          }
        }
        item.setText(2, newText);
      }
    });
    editorColumnY.addKeyListener(new KeyListener() {

      public void keyReleased(KeyEvent e) {
        // not used
      }
View Full Code Here

            new FastPartitioner(
                new DRLPartionScanner(),
                DRLPartionScanner.LEGAL_CONTENT_TYPES);
        partitioner.connect(document);
        document.setDocumentPartitioner(partitioner);
        importsViewer.getControl().addKeyListener(new KeyListener() {
            public void keyPressed(KeyEvent e) {
                if (e.character == ' ' && e.stateMask == SWT.CTRL) {
                    importsViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
                }
            }
View Full Code Here

            new FastPartitioner(
                new DRLPartionScanner(),
                DRLPartionScanner.LEGAL_CONTENT_TYPES);
        partitioner.connect(document);
        document.setDocumentPartitioner(partitioner);
        globalsViewer.getControl().addKeyListener(new KeyListener() {
            public void keyPressed(KeyEvent e) {
                if (e.character == ' ' && e.stateMask == SWT.CTRL) {
                    globalsViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
                }
            }
View Full Code Here

                    modeller.setDirty( true );
                }
            } );

            if ( this.numericValue ) {
                box.addKeyListener( new KeyListener() {

                    public void keyPressed(KeyEvent e) {
                        if ( Character.isLetter( e.character ) ) {
                            e.doit = false;
                        }
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.