Files
Brainstorm/Snippets/src/snippets/Bindings.java

82 lines
1.9 KiB
Java
Raw Normal View History

2014-05-30 10:31:51 -07:00
package snippets;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.CoolBar;
import org.eclipse.swt.widgets.CoolItem;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
/**
* Copyright Wynne Crisman 2006<p>
*/
public class Bindings {
/**
* Bindings constructor.
*/
public Bindings() {
super();
}
/**
* @param args
*/
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
CoolBar bar = new CoolBar(shell, SWT.BORDER);
for(int i=0; i<2; i++) {
CoolItem item = new CoolItem (bar, SWT.DROP_DOWN);
Button button = new Button (bar, SWT.PUSH);
button.setText ("Button " + i);
Point size = button.computeSize (SWT.DEFAULT, SWT.DEFAULT);
item.setPreferredSize (item.computeSize (size.x, size.y));
item.setControl (button);
}
bar.pack();
shell.open();
/*
<action>
<key code="a" modifiers="control | shift"
</action>
*/
shell.addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent e) {
//int key = e.keyCode;
//int modifiers = e.stateMask;
//int a = SWT.MOD1;
//a = SWT.CONTROL;
//a = SWT.ALT;
//a = SWT.SHIFT;
}
public void keyPressed(KeyEvent e) {
}
});
shell.addMouseListener(new MouseListener() {
public void mouseUp(MouseEvent e) {
//int button = e.button;
//int modifiers = e.stateMask;
}
public void mouseDown(MouseEvent e) {
}
public void mouseDoubleClick(MouseEvent e) {
}
});
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}