Java Code Examples for org.eclipse.swt.widgets.Control#isFocusControl()
The following examples show how to use
org.eclipse.swt.widgets.Control#isFocusControl() .
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: CDialogCellEditor.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Processes a focus lost event that occurred in this cell editor. * <p> * The default implementation of this framework method applies the current * value and deactivates the cell editor. Subclasses should call this method * at appropriate times. Subclasses may also extend or reimplement. * </p> */ private boolean checkFocusControl( Control control ) { if ( control.isFocusControl( ) ) return true; if ( control instanceof Composite ) { Control[] children = ((Composite)control).getChildren( ); if ( children != null ) { for ( int i = 0; i < children.length; i++ ) { if(checkFocusControl(children[i])) return true; } } } return false; }
Example 2
Source File: InternalCompositeTable.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * Make sure that something sane inside the table has focus. */ private void resetFocus() { /* * FEATURE IN WINDOWS: When we refresh all rows and one already has * focus, Windows gets into a schizophrenic state where some part of * Windows thinks that the current control has focus and another part of * Windows thinks that the current control doesn't have focus. * * The symptom is that the current control stops receiving events from * Windows but Windows still thinks the current control has focus and so * it won't give the control complete focus if you click on it. * * The workaround is to set the focus away from the currently-focused * control and to set it back. */ if (numRowsVisible < 1 || currentRow < 0) { return; } Control control = null; if (currentRow < numRowsVisible) { control = getControl(currentColumn, currentRow); } else if (currentRow > 0) { control = getControl(currentColumn, numRowsVisible - 1); } if (control != null && control.isFocusControl()) { this.setFocus(); deferredSetFocus(control, true); } }
Example 3
Source File: InternalCompositeTable.java From nebula with Eclipse Public License 2.0 | 5 votes |
/** * Set the focus to the specified (column, row). If rowChange is true, fire * a row change event, otherwise be silent. * * @param column * The 0-based column to focus * @param row * The 0-based row to focus * @param rowChange * true if a row change event should be fired; false otherwise. */ private void internalSetSelection(int column, int row, boolean rowChange) { Control toFocus = getControl(column, row); if (toFocus == null) { return; } if (toFocus.isFocusControl()) { toFocus.notifyListeners(SWT.FocusIn, new Event()); } else { deferredSetFocus(toFocus, rowChange); } }
Example 4
Source File: TextFieldNavigationHandler.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private FocusHandler(Navigable navigable) { fIterator= new JavaWordIterator(); fNavigable= navigable; Control control= navigable.getControl(); control.addFocusListener(this); if (control.isFocusControl()) activate(); control.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { deactivate(); } }); }
Example 5
Source File: Editor.java From Rel with Apache License 2.0 | 5 votes |
public static boolean hasFocus(Control control) { if (control.isFocusControl()) return true; if (control instanceof Composite) for (Control child : ((Composite) control).getChildren()) if (hasFocus(child)) return true; return false; }
Example 6
Source File: InternalCompositeTable.java From nebula with Eclipse Public License 2.0 | 4 votes |
public void widgetSelected(SelectionEvent e) { if (vSlider.getSelection() == topRow) { return; } if (!fireRequestRowChangeEvent()) { vSlider.setSelection(topRow); return; } deselectCurrentRowIfVisible(); int delta = topRow - vSlider.getSelection(); int oldCurrentRow = currentRow; currentRow = vSlider.getSelection(); // setTopRow(vSlider.getSelection()); // Removed as a result of patch doSetTopRow(vSlider.getSelection(), currentRow + delta); // If the focused row just became visible, show the focus if (oldCurrentRow < 0 || oldCurrentRow >= getNumRowsVisible()) { if (currentRow >= 0 && currentRow < getNumRowsVisible()) { Control newFocusControl = getControl(currentColumn, currentRow); if (newFocusControl == null) { return; } if (newFocusControl.isFocusControl()) { newFocusControl.notifyListeners(SWT.FocusIn, new Event()); } else { deferredSetFocus(newFocusControl, true); } } } else { // If the new viewport doesn't overlap the old one, hide the focus if (currentRow < 0 || currentRow >= getNumRowsVisible()) { // deleteRowAt(oldCurrentRow); // getControl(currentColumn, oldCurrentRow).getParent().setVisible(false); // getControl(currentColumn, oldCurrentRow).getParent().setVisible(true); Control control = getControl(currentColumn, oldCurrentRow); if (control != null) { control.notifyListeners(SWT.FocusOut, new Event()); } } } }
Example 7
Source File: CTreeEditor.java From nebula with Eclipse Public License 2.0 | 4 votes |
public void layout() { if (tree.isDisposed()) return; if (item == null || item.isDisposed()) return; int columnCount = tree.getColumnCount(); if (columnCount == 0 && column != 0) return; if (columnCount > 0 && (column < 0 || column >= columnCount)) return; Control editor = getEditor(); if(editor == null || editor.isDisposed()) return; Rectangle cell = item.getCell(column).getBounds(); Rectangle ca = item.getCell(column).getClientArea(); cell.x += ca.x; cell.width = ca.width - 1; cell.y += 1; cell.height -= 2; int bwidth = getEditor().getBorderWidth(); cell.x -= bwidth; cell.y -= bwidth; cell.width -= 2*bwidth; cell.height -= 2*bwidth; Image[] images = ((CTreeCell) item.getCell(column)).getImages(); if(images.length > 0) { Image img = images[images.length-1]; Rectangle rect = img == null ? new Rectangle(cell.x,cell.y,0,0) : img.getBounds(); cell.x = rect.x + rect.width; cell.width -= rect.width; } Rectangle area = tree.getClientArea(); if (cell.x < area.x + area.width) { if (cell.x + cell.width > area.x + area.width) { cell.width = area.x + area.width - cell.x; } } Rectangle editorRect = new Rectangle(cell.x, cell.y, minimumWidth, minimumHeight); if (grabHorizontal) { if (tree.getColumnCount() == 0) { // Bounds of tree item only include the text area - stretch out to include // entire client area cell.width = area.x + area.width - cell.x; } editorRect.width = Math.max(cell.width, minimumWidth); } if (grabVertical) { editorRect.height = Math.max(cell.height, minimumHeight); } if (horizontalAlignment == SWT.RIGHT) { editorRect.x += cell.width - editorRect.width; } else if (horizontalAlignment == SWT.LEFT) { // do nothing - cell.x is the right answer } else { // default is CENTER editorRect.x += (cell.width - editorRect.width)/2; } // don't let the editor overlap with the +/- of the tree editorRect.x = Math.max(cell.x, editorRect.x); if (verticalAlignment == SWT.BOTTOM) { editorRect.y += cell.height - editorRect.height; } else if (verticalAlignment == SWT.TOP) { // do nothing - cell.y is the right answer } else { // default is CENTER editorRect.y += (cell.height - editorRect.height)/2; } if(editor == null || editor.isDisposed()) return; boolean hadFocus = editor.getVisible () && editor.isFocusControl(); // this doesn't work because // resizing the column takes the focus away // before we get here editor.setBounds (editorRect); if(hadFocus) { if (editor == null || editor.isDisposed()) return; editor.setFocus (); } editor.moveAbove(null); }