Changeset 2094


Ignore:
Timestamp:
01/15/07 14:36:30 (13 years ago)
Author:
sorber
Message:

Changes to mouse logic for simultaneous L and R mouse clicks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/visbio/overlays/OverlayTransform.java

    r2024 r2094  
    9898  /** Whether left mouse button is currently being pressed. */ 
    9999  protected boolean mouseDownLeft; 
     100 
     101  /** Whether right mouse button is currently being pressed. */ 
     102  protected boolean mouseDownRight; 
    100103 
    101104  /** Font metrics for the current font. */ 
     
    686689 
    687690    if (id == DisplayEvent.TRANSFORM_DONE) updatePosition(display); 
     691    else if (id == DisplayEvent.MOUSE_PRESSED_RIGHT) { 
     692      mouseDownRight = true; 
     693      if (mouseDownLeft) releaseLeft(e, display, tool);  
     694    } 
     695    else if (id == DisplayEvent.MOUSE_RELEASED_RIGHT) mouseDownRight = false; 
    688696    else if (id == DisplayEvent.MOUSE_PRESSED_LEFT) { 
     697      if (mouseDownRight) return; 
    689698      mouseDownLeft = true; 
    690699      updatePosition(display); 
     
    697706    } 
    698707    else if (id == DisplayEvent.MOUSE_RELEASED_LEFT) { 
    699       mouseDownLeft = false; 
    700       updatePosition(display); 
    701       if (tool != null) { 
    702         double[] coords = 
    703           DisplayUtil.pixelToDomain(display, e.getX(), e.getY()); 
    704         tool.mouseUp((float) coords[0], (float) coords[1], 
    705           pos, e.getModifiers()); 
    706       } 
     708      if (!mouseDownLeft) return; 
     709      releaseLeft(e, display, tool); 
    707710    } 
    708711    else if (mouseDownLeft && id == DisplayEvent.MOUSE_DRAGGED) { 
     
    759762    } 
    760763  } 
     764  
     765  /** Helper method for Display Changed -- releases left mouse button */ 
     766  protected void releaseLeft(DisplayEvent e, DisplayImpl display, OverlayTool tool) { 
     767    mouseDownLeft = false; 
     768    updatePosition(display); 
     769    if (tool != null) { 
     770      double[] coords = 
     771        DisplayUtil.pixelToDomain(display, e.getX(), e.getY()); 
     772      tool.mouseUp((float) coords[0], (float) coords[1], 
     773        pos, e.getModifiers()); 
     774    } 
     775  } 
    761776 
    762777  // -- Dynamic API methods -- 
Note: See TracChangeset for help on using the changeset viewer.