下面列出了java.awt.event.MouseEvent#getButton() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void mouseReleased(MouseEvent e) {
if (mIsDragging && e.getButton() == MouseEvent.BUTTON1) {
final int deltaY = e.getYOnScreen() - mOriginalScreenY;
final int newY = mOriginalY + deltaY;
final Component[] components = getComponents();
// Find new position for mPanel (it is currently at position 0 due to Z order)
int i;
for (i = 1; i < components.length; ++i) {
if (components[i].getY() >= newY) {
break;
}
}
mPanel.setBorder(mBorder);
remove(mPanel);
add(mPanel, i - 1);
updateCurves();
mIsDragging = false;
}
}
@Override
public MouseEvent mouseClicked(MouseEvent e)
{
// Check if left click + alt
if (e.getButton() == MouseEvent.BUTTON1 && e.isAltDown())
{
final MenuEntry[] menuEntries = client.getMenuEntries();
for (final MenuEntry menuEntry : menuEntries)
{
if (menuEntry.getOption().equals(SEARCH_GRAND_EXCHANGE))
{
search(Text.removeTags(menuEntry.getTarget()));
e.consume();
break;
}
}
}
return super.mouseClicked(e);
}
@Override
public
void
mousePressed(MouseEvent event)
{
if(event.getSource() == getLabels()[RIGHT_LABEL] && event.getButton() == BUTTON1)
{
// Icons are only displayed on the right when the text field has focus.
if(getField().hasFocus() == true)
{
if(getLabels()[RIGHT_LABEL].getIcon() == SEARCH_CLEAR.getIcon())
{
getLabels()[RIGHT_LABEL].setIcon(SEARCH_CLEAR_PRESSED.getIcon());
}
}
}
}
@Override
public void mouseReleased(MouseEvent evt) {
if (dragIsSelected()) {
return;
}
final OpenTCSDrawingView drawingView = scrollPane.getDrawingView();
Figure fig = drawingView.findFigure(evt.getPoint());
if (fig instanceof LabeledPointFigure) {
createPossibleTransportOrder((LabeledPointFigure) fig, drawingView.getSelectedFigures());
}
pressedFigure = null;
fMouseEndPoint.setLocation(drawingView.viewToDrawing(evt.getPoint()));
if (evt.getButton() != 2) {
showPositionStatus(true);
}
else {
showPositionStatus(false);
}
}
@Override
protected void execute(final MouseEvent e) {
Optional<Runnable> first = myAdditionalIcons.stream().filter(icon -> mouseOverIcon(icon)).map(icon -> icon.getAction()).findFirst();
if (first.isPresent()) {
first.get().run();
return;
}
selectContent();
if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !myLayout.myDoubleClickActions.isEmpty()) {
DataContext dataContext = DataManager.getInstance().getDataContext(ContentTabLabel.this);
for (AnAction action : myLayout.myDoubleClickActions) {
AnActionEvent event = AnActionEvent.createFromInputEvent(e, ActionPlaces.UNKNOWN, null, dataContext);
if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) {
ActionManagerEx.getInstanceEx().fireBeforeActionPerformed(action, dataContext, event);
ActionUtil.performActionDumbAware(action, event);
}
}
}
}
@Override
public void mousePressed(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
x = e.getX();
y = e.getY();
}
}
private void checkExtraMouseButtons(MouseEvent mouseEvent)
{
// Prevent extra mouse buttons from being passed into the client,
// as it treats them all as left click
int button = mouseEvent.getButton();
if (button >= MOUSE_BUTTON_4 && runeLiteConfig.blockExtraMouseButtons())
{
mouseEvent.consume();
}
}
protected String ManageMemories(MouseEvent e, String memo) {
if (datalist.data.isEmpty())
return memo;
int row = TableData.getSelectedRow();
if (row < 0)
return memo;
// -- Left click
if (e.getButton() == MouseEvent.BUTTON1) {
int line = (int) datalist.data.get(row).getNum() - 1;
if (line > track.data.size())
return memo;
String txt = memo;
tfFormat.setText(txt);
track.data.get(line).FmtLbMiniRoadbook = txt;
datalist.data.get(row).FmtLbMiniRoadbook = txt;
track.isModified = true;
RefreshTableData();
pnlProfil.Refresh();
}
// -- Right click
else if (e.getButton() == MouseEvent.BUTTON3) {
memo = tfFormat.getText();
track.isModified = true;
// RefreshTooltips();
}
return memo;
}
public void mousePressed( final MouseEvent e ) {
final int padding = (int) getPadding();
if ( e.getX() < padding ) {
return;
}
if ( e.getButton() == MouseEvent.BUTTON1 ) {
guideLineIndex = getActiveGuideIndex( e );
if ( guideLineIndex != -1 ) {
setDraggedGuideLine( getLinealModel().getGuideLine( guideLineIndex ) );
}
}
}
@Override
public void mousePressed(MouseEvent e) {
if(e.getButton() == MouseEvent.BUTTON1) {
if(e.getClickCount() >= 2) {
int row = XMBeanAttributes.this.getSelectedRow();
int col = XMBeanAttributes.this.getSelectedColumn();
if(col != VALUE_COLUMN) return;
if(col == -1 || row == -1) return;
XMBeanAttributes.this.updateZoomedCell(row, col);
}
}
}
@Override
public
void
mouseClicked(MouseEvent event)
{
if(event.getButton() == MouseEvent.BUTTON1 && event.getClickCount() == 2)
{
// Make sure the user double-clicked on an element.
if(getChooser().getRowForLocation(event.getX(), event.getY()) != -1)
{
edit();
}
}
}
@Override
public void mousePressed(MouseEvent e) {
if(e.getButton() == MouseEvent.BUTTON1) {
if(e.getClickCount() >= 2) {
int row = XMBeanAttributes.this.getSelectedRow();
int col = XMBeanAttributes.this.getSelectedColumn();
if(col != VALUE_COLUMN) return;
if(col == -1 || row == -1) return;
XMBeanAttributes.this.updateZoomedCell(row, col);
}
}
}
@Override
public void mouseEntered(MouseEvent e) {
this.stateTransitionTracker.turnOffModelChangeTracking();
try {
super.mouseEntered(e);
this.isMouseInside = true;
boolean isMouseDrag = (e.getButton() == MouseEvent.BUTTON1);
if (!isMouseDrag) {
this.button.getModel().setRollover(true);
}
} finally {
this.stateTransitionTracker.onModelStateChanged();
}
}
/**
* This method cannot be called directly.
*/
@Override
public void mousePressed(MouseEvent e) {
synchronized (mouseLock) {
mouseX = userX(e.getX());
mouseY = userY(e.getY());
isMousePressed = true;
}
if (e.getButton() == MouseEvent.BUTTON1) {
for (DrawListener listener : listeners)
listener.mousePressed(userX(e.getX()), userY(e.getY()));
}
}
@Override
public void mousePressed(MouseEvent e) {
if(e.getButton() == MouseEvent.BUTTON1) {
if(e.getClickCount() >= 2) {
int row = XMBeanAttributes.this.getSelectedRow();
int col = XMBeanAttributes.this.getSelectedColumn();
if(col != VALUE_COLUMN) return;
if(col == -1 || row == -1) return;
XMBeanAttributes.this.updateZoomedCell(row, col);
}
}
}
@Override
public void mousePressed(MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON1) {
Point p = fixEventPoint(e.getPoint());
pressPoint = editor.getViewer().getCoordinatesAtPoint(p.x, p.y);
overlay.setLeft(pressPoint.getX());
overlay.setBottom(pressPoint.getY());
editor.getViewer().addOverlay(overlay);
editor.getViewer().repaint();
}
}
static boolean isLeftMouseButton(MouseEvent me) {
switch (me.getID()) {
case MouseEvent.MOUSE_PRESSED:
case MouseEvent.MOUSE_RELEASED:
return (me.getButton() == MouseEvent.BUTTON1);
case MouseEvent.MOUSE_ENTERED:
case MouseEvent.MOUSE_EXITED:
case MouseEvent.MOUSE_CLICKED:
case MouseEvent.MOUSE_DRAGGED:
return ((me.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0);
}
return false;
}
@Override
public void mousePressed(MouseEvent e) {
if (e.getButton() != MouseEvent.BUTTON1) {
return;
}
selecting = true;
selectionCorner1 = getTileLocation(e.getX(), e.getY());
selectionCorner2 = null;
imageViewer.setSelectedRectangleCorner1(null);
imageViewer.setSelectedRectangleCorner2(null);
}
@Override
public void mouseReleased(MouseEvent e) {
UIPoint local = convertToLocal(e);
if (e.getButton() == MouseEvent.BUTTON1) {
endDraw(local);
} else if (panWithButton3 && e.getButton() == MouseEvent.BUTTON3) {
endPan(local);
} else if (!panWithButton3 && e.getButton() == MouseEvent.BUTTON2) {
endPan(local);
}
}
public void mouseClicked( final MouseEvent e ) {
if ( e.getClickCount() > 1 && e.getButton() == MouseEvent.BUTTON1 ) {
setConfirmed( true );
QuerySelectorDialog.this.dispose();
}
}