- Timestamp:
- 2013-07-12T13:34:05+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/TagTable.java
r5266 r6063 5 5 6 6 import java.applet.Applet; 7 import java.awt.AWTException;8 7 import java.awt.Component; 9 8 import java.awt.Container; 10 9 import java.awt.Dimension; 11 10 import java.awt.KeyboardFocusManager; 12 import java.awt.MouseInfo;13 import java.awt.Point;14 import java.awt.Rectangle;15 import java.awt.Robot;16 11 import java.awt.Window; 17 12 import java.awt.event.ActionEvent; 18 import java.awt.event.InputEvent;19 13 import java.awt.event.KeyEvent; 20 14 import java.awt.event.KeyListener; … … 37 31 import javax.swing.table.DefaultTableColumnModel; 38 32 import javax.swing.table.TableColumn; 33 import javax.swing.text.JTextComponent; 39 34 40 35 import org.openstreetmap.josm.gui.dialogs.relation.RunnableAction; … … 132 127 class SelectPreviousColumnCellAction extends AbstractAction { 133 128 129 @Override 134 130 public void actionPerformed(ActionEvent e) { 135 131 int col = getSelectedColumn(); … … 244 240 * listens to the table selection model 245 241 */ 242 @Override 246 243 public void valueChanged(ListSelectionEvent e) { 247 244 updateEnabledState(); … … 289 286 } 290 287 288 @Override 291 289 public void propertyChange(PropertyChangeEvent evt) { 292 290 updateEnabledState(); … … 447 445 448 446 public void requestFocusInCell(final int row, final int col) { 449 450 // the following code doesn't work reliably. If a table cell 451 // gains focus using editCellAt() and requestFocusInWindow() 452 // it isn't possible to tab to the next table cell using TAB or 453 // ENTER. Don't know why. 454 // 455 // tblTagEditor.editCellAt(row, col); 456 // if (tblTagEditor.getEditorComponent() != null) { 457 // tblTagEditor.getEditorComponent().requestFocusInWindow(); 458 // } 459 460 // this is a workaround. We move the focus to the respective cell 461 // using a simulated mouse click. In this case one can tab out of 462 // the cell using TAB and ENTER. 463 // 464 Rectangle r = getCellRect(row,col, false); 465 Point p = new Point(r.x + r.width/2, r.y + r.height/2); 466 SwingUtilities.convertPointToScreen(p, this); 467 Point before = MouseInfo.getPointerInfo().getLocation(); 468 469 try { 470 Robot robot = new Robot(); 471 robot.mouseMove(p.x,p.y); 472 robot.mousePress(InputEvent.BUTTON1_MASK); 473 robot.mouseRelease(InputEvent.BUTTON1_MASK); 474 robot.mouseMove(before.x, before.y); 475 } catch(AWTException e) { 476 System.out.println("Failed to simulate mouse click event at (" + r.x + "," + r.y + "). Exception: " + e.toString()); 477 return; 478 } 447 editCellAt(row, col); 448 Component c = getEditorComponent(); 449 if (c!=null) { 450 c.requestFocusInWindow(); 451 if ( c instanceof JTextComponent ) { 452 ( (JTextComponent)c ).selectAll(); 453 } 454 } 455 // there was a bug here - on older 1.6 Java versions Tab was not working 456 // after such activation. In 1.7 it works OK, 457 // previous solution of usint awt.Robot was resetting mouse speed on Windows 479 458 } 480 459 … … 553 532 } 554 533 534 @Override 555 535 public void propertyChange(PropertyChangeEvent ev) { 556 536 if (!isEditing())
Note:
See TracChangeset
for help on using the changeset viewer.