Example usage for org.eclipse.swt.custom StyledText setKeyBinding

List of usage examples for org.eclipse.swt.custom StyledText setKeyBinding

Introduction

In this page you can find the example usage for org.eclipse.swt.custom StyledText setKeyBinding.

Prototype

public void setKeyBinding(int key, int action) 

Source Link

Document

Maps a key to an action.

Usage

From source file:StyledTextSetKeyBinding.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);

    StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER);
    styledText.setText("12345");

    styledText.setKeyBinding('i' | SWT.ALT, ST.TOGGLE_OVERWRITE);

    styledText.setBounds(10, 10, 100, 100);
    shell.open();//www.j a v a  2  s. c om
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}

From source file:StyledTextClearKeyBinding.java

public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);

    StyledText styledText = new StyledText(shell, SWT.V_SCROLL | SWT.BORDER);
    styledText.setText("12345");

    styledText.setKeyBinding('i' | SWT.ALT, ST.TOGGLE_OVERWRITE);

    //clear//from  w  ww  . j av a 2  s.  c  o  m
    styledText.setKeyBinding('i' | SWT.ALT, SWT.NULL);

    styledText.setBounds(10, 10, 100, 100);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();

}