Java Code Examples for org.eclipse.swt.SWT#KeyUp
The following examples show how to use
org.eclipse.swt.SWT#KeyUp .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FXCanvasEx.java From gef with Eclipse Public License 2.0 | 6 votes |
@Override public void removeListener(int eventType, Listener listener) { // XXX: Overwritten to ensure proper ordering of key listeners, // which is required to properly forward the consumption state to // the embedded scene (see // https://bugs.openjdk.java.net/browse/JDK-8159227). if (eventType == SWT.KeyUp) { if (listener == keyListener) { super.removeListener(eventType, listener); } else { keyUpListeners.remove(listener); } } else if (eventType == SWT.KeyDown) { if (listener == keyListener) { super.removeListener(eventType, listener); } else { keyDownListeners.remove(listener); } } else { super.removeListener(eventType, listener); } }
Example 2
Source File: ResourceDependencySection.java From uima-uimaj with Apache License 2.0 | 6 votes |
@Override public void handleEvent(Event event) { if (event.widget == addButton) { handleAdd(); } else if (event.widget == removeButton || (event.type == SWT.KeyUp && event.character == SWT.DEL)) { handleRemove(); } else if (event.widget == editButton || event.type == SWT.MouseDoubleClick) { handleEdit(); } // else if (event.type == SWT.MouseDown && event.button == 3) { // handleTableContextMenuRequest(event); // } else if (event.type == SWT.MouseHover) { handleTableHoverHelp(event); } else if (event.type == SWT.Selection) { editor.getResourcesPage().getResourceBindingsSection().enable(); } enable(); }
Example 3
Source File: StyleCombo.java From birt with Eclipse Public License 1.0 | 5 votes |
void createPopup( Object[] items, int selectionIndex ) { // create shell and list popup = new Shell( getShell( ), SWT.NO_TRIM | SWT.ON_TOP ); table = new Table( popup, SWT.SINGLE | SWT.V_SCROLL | SWT.FULL_SELECTION ); new TableColumn( table, SWT.LEFT ); if ( font != null ) table.setFont( font ); if ( foreground != null ) table.setForeground( foreground ); if ( background != null ) table.setBackground( background ); label.setBackground( table.getBackground( ) ); label.setForeground( table.getForeground( ) ); label.setFont( table.getFont( ) ); int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate }; for ( int i = 0; i < popupEvents.length; i++ ) popup.addListener( popupEvents[i], listener ); int[] tableEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.FocusOut, SWT.Dispose }; for ( int i = 0; i < tableEvents.length; i++ ) table.addListener( tableEvents[i], listener ); }
Example 4
Source File: KbdMacroExecuteHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
private Event upEvent(VerifyEvent event) { Event e = new Event(); e.keyCode = event.keyCode; e.character = event.character; e.stateMask = event.stateMask; e.type = SWT.KeyUp; e.doit = true; return e; }
Example 5
Source File: CapabilitySection.java From uima-uimaj with Apache License 2.0 | 5 votes |
@Override public void handleEvent(Event event) { if (event.type == SWT.Expand || event.type == SWT.Collapse) { pack04(); return; } if (event.widget == addCapabilityButton) { handleAddCapability(); enable(); return; } TreeItem selItem = tt.getSelection()[0]; int itemKind = getItemKind(selItem); if (event.widget == addLangButton) { handleAddLang(selItem, itemKind); } else if (event.widget == addTypeButton) { handleAddType(selItem, itemKind); } else if (event.widget == addSofaButton) { handleAddSofa(selItem, itemKind); } else if (event.widget == addEditFeatureButton) { handleAddEditFeature(selItem, itemKind); } else if (event.widget == editButton || event.type == SWT.MouseDoubleClick) { handleEdit(selItem, itemKind); } else if (event.widget == removeButton || (event.widget == tt && event.type == SWT.KeyUp && event.character == SWT.DEL)) { handleRemove(selItem, itemKind); } enable(); }
Example 6
Source File: TableCombo.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * creates the popup shell. * @param selectionIndex */ void createPopup(int selectionIndex) { // create shell and table popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP); // create table table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION); if (font != null) table.setFont(font); if (foreground != null) table.setForeground(foreground); if (background != null) table.setBackground(background); // Add popup listeners int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate }; for (int i = 0; i < popupEvents.length; i++) { popup.addListener(popupEvents[i], listener); } // add table listeners int[] tableEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose }; for (int i = 0; i < tableEvents.length; i++) { table.addListener(tableEvents[i], listener); } // set the selection if (selectionIndex != -1) { table.setSelection(selectionIndex); } }
Example 7
Source File: SwtBotTestingUtilities.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
/** * Injects a key or character via down and up events. Only one of {@code keyCode} or * {@code character} must be provided. Use * * @param keyCode the keycode of the key (use {@code 0} if unspecified) * @param character the character to press (use {@code '\0'} if unspecified) */ public static void sendKeyDownAndUp(SWTBot bot, int keyCode, char character) { Event ev = new Event(); ev.keyCode = keyCode; ev.character = character; ev.type = SWT.KeyDown; bot.getDisplay().post(ev); bot.sleep(EVENT_DOWN_UP_DELAY_MS); ev.type = SWT.KeyUp; bot.getDisplay().post(ev); }
Example 8
Source File: DiskExplorerTab.java From AppleCommander with GNU General Public License v2.0 | 5 votes |
/** * Create the keyboard handler for the file pane. * These are keys that are <em>only</em> active in the file * viewer. See createToolbarCommandHandler for the general application * keyboard handler. * @see #createToolbarCommandHandler */ private Listener createFileKeyboardHandler() { return new Listener() { public void handleEvent(Event event) { FileEntry fileEntry = getSelectedFileEntry(); if (fileEntry != null && event.type == SWT.KeyUp && (event.stateMask & SWT.CTRL) != 0) { try { switch (event.character) { case CTRL_C: // Compile Wizard if (getCompileToolItem().isEnabled()) { compileFileWizard(); } break; case CTRL_D: // Delete file if (getDeleteToolItem().isEnabled()) { deleteFile(); } break; case CTRL_E: // Export Wizard exportFileWizard(); break; case CTRL_V: // View file viewFile(null); break; } } catch (DiskException e) { DiskExplorerTab.this.diskWindow.handle(e); } } } }; }
Example 9
Source File: DiskExplorerTab.java From AppleCommander with GNU General Public License v2.0 | 5 votes |
/** * Create the keyboard handler for the directory pane. * These are keys that are <em>only</em> active in the directory * viewer. See createToolbarCommandHandler for the general application * keyboard handler. * @see #createToolbarCommandHandler */ private Listener createDirectoryKeyboardHandler() { return new Listener() { public void handleEvent(Event event) { if (event.type == SWT.KeyUp) { TreeItem[] treeItem = null; if ((event.stateMask & SWT.CTRL) != 0) { switch (event.character) { case '-': treeItem = getDirectoryTree().getSelection(); setDirectoryExpandedStates(treeItem[0], false); break; case '+': treeItem = getDirectoryTree().getSelection(); setDirectoryExpandedStates(treeItem[0], true); break; } } else { // assume no control and no alt switch (event.character) { case '-': treeItem = getDirectoryTree().getSelection(); treeItem[0].setExpanded(false); break; case '+': treeItem = getDirectoryTree().getSelection(); treeItem[0].setExpanded(true); break; } } } } }; }
Example 10
Source File: MultiValueCombo.java From birt with Eclipse Public License 1.0 | 5 votes |
public void addListener( int eventType, Listener listener ) { if ( addListenerLock == true && ( eventType == SWT.Selection || eventType == SWT.KeyUp || eventType == SWT.KeyDown ) ) { return; } super.addListener( eventType, listener ); }
Example 11
Source File: VControl.java From nebula with Eclipse Public License 2.0 | 5 votes |
private boolean include(boolean key, int type) { if(type == SWT.Selection) { return false; } if(key && (type == SWT.KeyDown || type == SWT.KeyUp || type == SWT.Traverse)) { return true; } if(!key && !(type == SWT.KeyDown || type == SWT.KeyUp || type == SWT.Traverse)) { return true; } return false; }
Example 12
Source File: AggregateSection.java From uima-uimaj with Apache License 2.0 | 5 votes |
@Override public void handleEvent(Event event) { if (event.widget == addButton) handleAdd(); else if (event.widget == removeButton || (event.type == SWT.KeyUp && event.character == SWT.DEL)) handleRemove(); else if (event.widget == addToFlowButton) handleAddToFlow(); else if (event.widget == removeFromFlowButton) handleRemoveFromFlow(); else if (event.widget == addRemoteButton) handleAddRemote(); else if (event.widget == findAnalysisEngineButton) handleFindAnalysisEngine(); // actions on table else if (event.widget == filesTable) { if (event.type == SWT.Selection) { // if no delegate is selected disable edit and remove boolean bEnableButtons = (filesTable.getSelectionCount() > 0); removeButton.setEnabled(bEnableButtons); addToFlowButton.setEnabled(bEnableButtons); } else if (event.type == SWT.MouseDown && (event.button == 3 || // this is for Macintosh - they just have one button (event.button == 1 && (0 != (event.stateMask & SWT.CTRL))))) { handleTableContextMenuRequest(event); } else if (event.type == SWT.MouseHover && !bDisableToolTipHelp) { handleTableHoverHelp(event); } // Don't need this. Next mouse hover kills tool tip anyway // else if (event.type == SWT.MouseMove) { // filesTable.setToolTipText(""); // } } }
Example 13
Source File: CustomCombo.java From nebula with Eclipse Public License 2.0 | 5 votes |
void createPopup(String[] items, int selectionIndex) { // create shell and list popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP); int style = getStyle(); int listStyle = SWT.SINGLE | SWT.V_SCROLL; if ((style & SWT.FLAT) != 0) listStyle |= SWT.FLAT; if ((style & SWT.RIGHT_TO_LEFT) != 0) listStyle |= SWT.RIGHT_TO_LEFT; if ((style & SWT.LEFT_TO_RIGHT) != 0) listStyle |= SWT.LEFT_TO_RIGHT; list = new List(popup, listStyle); if (font != null) list.setFont(font); if (foreground != null) list.setForeground(foreground); if (background != null) list.setBackground(background); int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate }; for (int i = 0; i < popupEvents.length; i++) popup.addListener(popupEvents[i], listener); int[] listEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose }; for (int i = 0; i < listEvents.length; i++) list.addListener(listEvents[i], listener); if (items != null) list.setItems(items); if (selectionIndex != -1) list.setSelection(selectionIndex); }
Example 14
Source File: KbdMacroExecuteHandler.java From e4macs with Eclipse Public License 1.0 | 4 votes |
/** * Create the Runnable for posting a key event * * @param event * @param editor * @return the Runnable */ private Runnable getKeyRunner(final KbdEvent event, ITextEditor editor) { final KbdMacroExecuteHandler executeHandler = this; return new Runnable() { Event ee = event.getEvent(); public void run() { if (executeHandler.isInterrupted()){ return; } // to support internal Emacs+ control sequences in minibuffer commands: // The .post event ignores the stateMask, so force CTRL/ALT/Shift keys manually when required Event shiftless = null; Event ctrlless = null; Event altless = null; Event cmdless = null; Display display = PlatformUI.getWorkbench().getDisplay(); try { if (ee.stateMask != 0) { if ((ee.stateMask & SWT.SHIFT) != 0){ shiftless = KbdMacroExecuteHandler.this.maskEvent(SWT.SHIFT); display.post(shiftless); } if ((ee.stateMask & SWT.CTRL) != 0) { ctrlless = KbdMacroExecuteHandler.this.maskEvent(SWT.CTRL); display.post(ctrlless); } if ((ee.stateMask & SWT.ALT) != 0) { altless = KbdMacroExecuteHandler.this.maskEvent(SWT.ALT); display.post(altless); } if ((ee.stateMask & SWT.COMMAND) != 0) { cmdless = KbdMacroExecuteHandler.this.maskEvent(SWT.COMMAND); display.post(cmdless); } } ee.doit = true; ee.type = SWT.KeyDown; executeHandler.setKeyEvent(ee); display.post(ee); // System.out.println("post " + ee.character); } finally { if (ee.stateMask != 0) { if (shiftless != null) { shiftless.type = SWT.KeyUp; shiftless.doit = true; display.post(shiftless); } if (ctrlless != null) { ctrlless.type = SWT.KeyUp; ctrlless.doit = true; display.post(ctrlless); } if (altless != null) { altless.type = SWT.KeyUp; altless.doit = true; display.post(altless); } if (cmdless != null) { cmdless.type = SWT.KeyUp; cmdless.doit = true; display.post(cmdless); } } } } }; }
Example 15
Source File: CCombo.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Constructs a new instance of this class given its parent * and a style value describing its behavior and appearance. * <p> * The style value is either one of the style constants defined in * class <code>SWT</code> which is applicable to instances of this * class, or must be built by <em>bitwise OR</em>'ing together * (that is, using the <code>int</code> "|" operator) two or more * of those <code>SWT</code> style constants. The class description * lists the style constants that are applicable to the class. * Style bits are also inherited from superclasses. * </p> * * @param parent a widget which will be the parent of the new instance (cannot be null) * @param style the style of widget to construct * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> * </ul> * * @see SWT#BORDER * @see SWT#READ_ONLY * @see SWT#FLAT * @see Widget#getStyle() */ public CCombo (Composite parent, int style) { super (parent, style = checkStyle (style)); int textStyle = SWT.SINGLE; if ((style & SWT.READ_ONLY) != 0) textStyle |= SWT.READ_ONLY; if ((style & SWT.FLAT) != 0) textStyle |= SWT.FLAT; text = new Text (this, textStyle); int arrowStyle = SWT.ARROW | SWT.DOWN; if ((style & SWT.FLAT) != 0) arrowStyle |= SWT.FLAT; arrow = new Button (this, arrowStyle); listener = new Listener () { public void handleEvent (Event event) { if (popup == event.widget) { popupEvent (event); return; } if (text == event.widget) { textEvent (event); return; } if (list == event.widget) { listEvent (event); return; } if (arrow == event.widget) { arrowEvent (event); return; } if (CCombo.this == event.widget) { comboEvent (event); return; } } }; int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize}; for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener); int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.Traverse, SWT.FocusIn, SWT.FocusOut}; for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener); int [] arrowEvents = {SWT.Selection, SWT.FocusIn, SWT.FocusOut}; for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener); createPopup(null, -1); initAccessible(); }
Example 16
Source File: CTreeCombo.java From nebula with Eclipse Public License 2.0 | 4 votes |
void createPopup(Collection<CTreeComboItem> items, CTreeComboItem selectedItem) { // create shell and list popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP); final int style = getStyle(); int listStyle = SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE; if ((style & SWT.FLAT) != 0) { listStyle |= SWT.FLAT; } if ((style & SWT.RIGHT_TO_LEFT) != 0) { listStyle |= SWT.RIGHT_TO_LEFT; } if ((style & SWT.LEFT_TO_RIGHT) != 0) { listStyle |= SWT.LEFT_TO_RIGHT; } tree = new Tree(popup, listStyle); tree.addTreeListener(hookListener); if (font != null) { tree.setFont(font); } if (foreground != null) { tree.setForeground(foreground); } if (background != null) { tree.setBackground(background); } final int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate }; for (int i = 0; i < popupEvents.length; i++) { popup.addListener(popupEvents[i], listener); } final int[] listEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose, SWT.Collapse, SWT.Expand }; for (int i = 0; i < listEvents.length; i++) { tree.addListener(listEvents[i], listener); } for (final CTreeComboColumn c : columns) { final TreeColumn col = new TreeColumn(tree, SWT.NONE); c.setRealTreeColumn(col); } if (items != null) { createTreeItems(items.toArray(new CTreeComboItem[0])); } if (selectedItem != null) { tree.setSelection(selectedItem.getRealTreeItem()); } }
Example 17
Source File: CTreeCombo.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** * The CTreeCombo class represents a selectable user interface object * that combines a text field and a tree and issues notification * when an item is selected from the tree. * <p> * Note that although this class is a subclass of <code>Composite</code>, * it does not make sense to add children to it, or set a layout on it. * </p> * <dl> * <dt><b>Styles:</b> * <dd>BORDER, READ_ONLY, FLAT</dd> * <dt><b>Events:</b> * <dd>DefaultSelection, Modify, Selection, Verify</dd> * </dl> */ public CTreeCombo(Composite parent, int style) { super(parent, style = checkStyle(style)); int textStyle = SWT.SINGLE; if ((style & SWT.READ_ONLY) != 0) { textStyle |= SWT.READ_ONLY; } if ((style & SWT.FLAT) != 0) { textStyle |= SWT.FLAT; } text = new Text(this, textStyle); int arrowStyle = SWT.ARROW | SWT.DOWN; if ((style & SWT.FLAT) != 0) { arrowStyle |= SWT.FLAT; } arrow = new Button(this, arrowStyle); listener = new Listener() { @Override public void handleEvent(Event event) { if (popup == event.widget) { popupEvent(event); return; } if (text == event.widget) { textEvent(event); return; } if (tree == event.widget) { treeEvent(event); return; } if (arrow == event.widget) { arrowEvent(event); return; } if (CTreeCombo.this == event.widget) { comboEvent(event); return; } if (getShell() == event.widget) { getDisplay().asyncExec(new Runnable() { @Override public void run() { if (isDisposed()) { return; } handleFocus(SWT.FocusOut); } }); } } }; filter = (event) -> { final Shell shell = ((Control) event.widget).getShell(); if (shell == CTreeCombo.this.getShell()) { handleFocus(SWT.FocusOut); } }; final int[] comboEvents = { SWT.Dispose, SWT.FocusIn, SWT.Move, SWT.Resize }; for (int i = 0; i < comboEvents.length; i++) { addListener(comboEvents[i], listener); } final int[] textEvents = { SWT.DefaultSelection, SWT.KeyDown, SWT.KeyUp, SWT.MenuDetect, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.MouseDoubleClick, SWT.MouseWheel, SWT.Traverse, SWT.FocusIn, SWT.Verify }; for (int i = 0; i < textEvents.length; i++) { text.addListener(textEvents[i], listener); } final int[] arrowEvents = { SWT.MouseDown, SWT.MouseUp, SWT.Selection, SWT.FocusIn }; for (int i = 0; i < arrowEvents.length; i++) { arrow.addListener(arrowEvents[i], listener); } createPopup(null, null); initAccessible(); }
Example 18
Source File: TableCombo.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * creates the popup shell. * @param selectionIndex */ void createPopup(int selectionIndex) { // create shell and table popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP); // set style int style = getStyle(); int tableStyle = SWT.SINGLE | SWT.V_SCROLL; if ((style & SWT.FLAT) != 0) tableStyle |= SWT.FLAT; if ((style & SWT.RIGHT_TO_LEFT) != 0) tableStyle |= SWT.RIGHT_TO_LEFT; if ((style & SWT.LEFT_TO_RIGHT) != 0) tableStyle |= SWT.LEFT_TO_RIGHT; // create table table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION); if (font != null) table.setFont(font); if (foreground != null) table.setForeground(foreground); if (background != null) table.setBackground(background); // Add popup listeners int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate, SWT.Help }; for (int i = 0; i < popupEvents.length; i++) { popup.addListener(popupEvents[i], listener); } // add table listeners int[] tableEvents = { SWT.MouseMove, SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose }; for (int i = 0; i < tableEvents.length; i++) { table.addListener(tableEvents[i], listener); } // set the selection if (selectionIndex != -1) { table.setSelection(selectionIndex); } }
Example 19
Source File: TableCombo.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * creates the popup shell. * @param selectionIndex */ void createPopup(int selectionIndex) { // create shell and table popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP); // set style int style = getStyle(); int tableStyle = SWT.SINGLE | SWT.V_SCROLL; if ((style & SWT.FLAT) != 0) tableStyle |= SWT.FLAT; if ((style & SWT.RIGHT_TO_LEFT) != 0) tableStyle |= SWT.RIGHT_TO_LEFT; if ((style & SWT.LEFT_TO_RIGHT) != 0) tableStyle |= SWT.LEFT_TO_RIGHT; // create table table = new Table(popup, SWT.SINGLE | SWT.FULL_SELECTION); if (font != null) table.setFont(font); if (foreground != null) table.setForeground(foreground); if (background != null) table.setBackground(background); // Add popup listeners int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate, SWT.Help }; for (int i = 0; i < popupEvents.length; i++) { popup.addListener(popupEvents[i], listener); } // add table listeners int[] tableEvents = { SWT.MouseMove, SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose }; for (int i = 0; i < tableEvents.length; i++) { table.addListener(tableEvents[i], listener); } // set the selection if (selectionIndex != -1) { table.setSelection(selectionIndex); } }
Example 20
Source File: DataItemCombo.java From birt with Eclipse Public License 1.0 | 4 votes |
void createPopup( String[] items, int selectionIndex ) { // create shell and list popup = new Shell( getShell( ), SWT.NO_TRIM | SWT.ON_TOP ); int style = getStyle( ); int listStyle = SWT.SINGLE | SWT.V_SCROLL; if ( ( style & SWT.FLAT ) != 0 ) listStyle |= SWT.FLAT; if ( ( style & SWT.RIGHT_TO_LEFT ) != 0 ) listStyle |= SWT.RIGHT_TO_LEFT; if ( ( style & SWT.LEFT_TO_RIGHT ) != 0 ) listStyle |= SWT.LEFT_TO_RIGHT; list = new List( popup, listStyle ); if ( font != null ) list.setFont( font ); if ( foreground != null ) list.setForeground( foreground ); if ( background != null ) list.setBackground( background ); int[] popupEvents = { SWT.Close, SWT.Paint, SWT.Deactivate }; for ( int i = 0; i < popupEvents.length; i++ ) popup.addListener( popupEvents[i], listener ); int[] listEvents = { SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose }; for ( int i = 0; i < listEvents.length; i++ ) list.addListener( listEvents[i], listener ); if ( items != null ) list.setItems( items ); if ( selectionIndex != -1 ) list.setSelection( selectionIndex ); }