コード例 #1
0
 /*
  * This overloaded method is for TrayIcon.
  * Its popup has special parent.
  */
 void show(Component origin, Point p) {
   WComponentPeer peer = (WComponentPeer) WToolkit.targetToPeer(origin);
   Event e = new Event(origin, 0, Event.MOUSE_DOWN, p.x, p.y, 0, 0);
   if (peer == null) {
     Component nativeOrigin = WToolkit.getNativeContainer(origin);
     e.target = nativeOrigin;
   }
   e.x = p.x;
   e.y = p.y;
   _show(e);
 }
コード例 #2
0
  public void show(Event e) {
    Component origin = (Component) e.target;
    WComponentPeer peer = (WComponentPeer) WToolkit.targetToPeer(origin);
    if (peer == null) {
      // A failure to map the peer should only happen for a
      // lightweight component, then find the actual native parent from
      // that component.  The event coorinates are going to have to be
      // remapped as well.
      Component nativeOrigin = WToolkit.getNativeContainer(origin);
      e.target = nativeOrigin;

      // remove the event coordinates
      for (Component c = origin; c != nativeOrigin; c = c.getParent()) {
        Point p = c.getLocation();
        e.x += p.x;
        e.y += p.y;
      }
    }
    _show(e);
  }