@Override public final void mousePressed(final MouseEvent e) { if (!isEnabled() || !isFocusable()) return; requestFocusInWindow(); caret(true); if (SwingUtilities.isMiddleMouseButton(e)) copy(); final boolean shift = e.isShiftDown(); final boolean selected = editor.selected(); if (SwingUtilities.isLeftMouseButton(e)) { final int c = e.getClickCount(); if (c == 1) { // selection mode if (shift) editor.startSelection(true); select(e.getPoint(), !shift); } else if (c == 2) { editor.selectWord(); } else { editor.selectLine(); } } else if (!selected) { select(e.getPoint(), true); } }
private void adjustFocusAndSelection(MouseEvent e) { if (shouldIgnore(e)) { return; } Point p = e.getPoint(); int row = grid.rowAtPoint(p); int column = grid.columnAtPoint(p); // The autoscroller can generate drag events outside range. if ((column == -1) || (row == -1)) { System.err.println("Out of bounds"); return; } if (grid.editCellAt(row, column, e)) { setDispatchComponent(e); repostEvent(e); } else { grid.requestFocus(); } GridCellEditor editor = grid.getCurrentCellEditor(); if (editor == null || editor.shouldSelectCell(e)) { // Update selection model setValueIsAdjusting(true); grid.changeSelection(row, column, e.isControlDown(), e.isShiftDown()); } }
@Override public final void mousePressed(final MouseEvent e) { if (!isEnabled() || !isFocusable()) return; requestFocusInWindow(); cursor(true); if (SwingUtilities.isMiddleMouseButton(e)) copy(); final boolean marking = e.isShiftDown(); final boolean nomark = !text.marked(); if (SwingUtilities.isLeftMouseButton(e)) { final int c = e.getClickCount(); if (c == 1) { // selection mode if (marking && nomark) text.startMark(); rend.select(scroll.pos(), e.getPoint(), marking); } else if (c == 2) { text.selectWord(); } else { text.selectLine(); } } else if (nomark) { rend.select(scroll.pos(), e.getPoint(), false); } }
void setRoiModState(MouseEvent e, Roi roi, int handle) { if (roi == null || (handle >= 0 && roi.modState == Roi.NO_MODS)) return; if (roi.state == Roi.CONSTRUCTING) return; int tool = Toolbar.getToolId(); if (tool > Toolbar.FREEROI && tool != Toolbar.WAND && tool != Toolbar.POINT) { roi.modState = Roi.NO_MODS; return; } if (e.isShiftDown()) roi.modState = Roi.ADD_TO_ROI; else if (e.isAltDown()) roi.modState = Roi.SUBTRACT_FROM_ROI; else roi.modState = Roi.NO_MODS; // IJ.log("setRoiModState: "+roi.modState+" "+ roi.state); }
// {{{ mouseClicked() method @Override public void mouseClicked(MouseEvent evt) { Point p = evt.getPoint(); int row = table.rowAtPoint(p); int column = table.columnAtPoint(p); if (row == -1) return; if (column == 0) { VFSDirectoryEntryTableModel.Entry entry = (VFSDirectoryEntryTableModel.Entry) table.getModel().getValueAt(row, 0); if (FileCellRenderer.ExpansionToggleBorder.isExpansionToggle(entry.level, p.x)) { return; } } if ((evt.getModifiers() & InputEvent.BUTTON1_MASK) != 0 && evt.getClickCount() % 2 == 0) { browser.filesActivated( evt.isShiftDown() ? VFSBrowser.M_OPEN_NEW_VIEW : VFSBrowser.M_OPEN, true); } else if (GUIUtilities.isMiddleButton(evt.getModifiers())) { if (evt.isShiftDown()) table.getSelectionModel().addSelectionInterval(row, row); else table.getSelectionModel().setSelectionInterval(row, row); browser.filesActivated( evt.isShiftDown() ? VFSBrowser.M_OPEN_NEW_VIEW : VFSBrowser.M_OPEN, true); } } // }}}
public void mouseDragged(MouseEvent e) { if (!e.isShiftDown()) // normal drag move(this, e); else // drag entire connected component { ArrayList connectedNodes = dNode.connectedNodes(); if (connectedNodes.size() == 0) move(this, e); else for (Iterator it = connectedNodes.iterator(); it.hasNext(); ) { ASDDigraphNode dNode2 = (ASDDigraphNode) it.next(); ASDEditNode eNode2 = dNode2.getEditNode(); move(eNode2, e); } } getEditor().setGrammarChanged(true); getContext().repaint(); }
public void mouseClicked(MouseEvent e) { JTableHeader h = (JTableHeader) e.getSource(); TableColumnModel columnModel = h.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = columnModel.getColumn(viewColumn).getModelIndex(); if (column != -1) { int status = getSortingStatus(column); if (!e.isControlDown()) { cancelSorting(); } // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed. status = status + (e.isShiftDown() ? -1 : 1); status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1} setSortingStatus(column, status); } }
// {{{ mousePressed() method @Override public void mousePressed(MouseEvent evt) { Point p = evt.getPoint(); if (evt.getSource() != table) { p.x -= table.getX(); p.y -= table.getY(); } int row = table.rowAtPoint(p); int column = table.columnAtPoint(p); if (column == 0 && row != -1) { VFSDirectoryEntryTableModel.Entry entry = (VFSDirectoryEntryTableModel.Entry) table.getModel().getValueAt(row, 0); if (FileCellRenderer.ExpansionToggleBorder.isExpansionToggle(entry.level, p.x)) { table.toggleExpanded(row); return; } } if (GUIUtilities.isMiddleButton(evt.getModifiers())) { if (row == -1) /* nothing */ ; else if (evt.isShiftDown()) table.getSelectionModel().addSelectionInterval(row, row); else table.getSelectionModel().setSelectionInterval(row, row); } else if (GUIUtilities.isPopupTrigger(evt)) { if (popup != null && popup.isVisible()) { popup.setVisible(false); popup = null; return; } if (row == -1) showFilePopup(null, table, evt.getPoint()); else { if (!table.getSelectionModel().isSelectedIndex(row)) table.getSelectionModel().setSelectionInterval(row, row); showFilePopup(getSelectedFiles(), table, evt.getPoint()); } } } // }}}