Пример #1
0
/* void click (in nsISupports aNode, in long x, in long y, in long button); */
NS_IMETHODIMP nsNativeEvents::Click(nsISupports *aNode, PRInt32 x, PRInt32 y, PRInt32 button)
{
  AccessibleDocumentWrapper doc(aNode);

  void* windowHandle = doc.getWindowHandle();
  LOG(DEBUG) << "Have click window handle: " << windowHandle;

  if (!windowHandle) {
    LOG(WARN) << "No window handle!";
    return NS_ERROR_NULL_POINTER;
  }

  LOG(DEBUG) << "Calling clickAt: " << x << ", " << y;
  WD_RESULT res = clickAt(windowHandle, x, y, button);

  LOG(DEBUG) << "Result was: " << (res == SUCCESS ? "ok" : "fail");

  return res == SUCCESS ? NS_OK : NS_ERROR_FAILURE;
}
Пример #2
0
int Element::Click(const ELEMENT_SCROLL_BEHAVIOR scroll_behavior) {
  LOG(TRACE) << "Entering Element::Click";

  long x = 0, y = 0, w = 0, h = 0;
  int status_code = this->GetLocationOnceScrolledIntoView(scroll_behavior, &x, &y, &w, &h);

  if (status_code == SUCCESS) {
    long click_x;
    long click_y;
    GetClickPoint(x, y, w, h, &click_x, &click_y);

    // Create a mouse move, mouse down, mouse up OS event
    LRESULT result = mouseMoveTo(this->containing_window_handle_,
                                 /* duration of move in ms = */ 10,
                                 x,
                                 y,
                                 click_x,
                                 click_y);
    if (result != SUCCESS) {
      LOG(WARN) << "Unable to move mouse, mouseMoveTo returned non-zero value";
      return static_cast<int>(result);
    }
    
    result = clickAt(this->containing_window_handle_,
                     click_x,
                     click_y,
                     MOUSEBUTTON_LEFT);
    if (result != SUCCESS) {
      LOG(WARN) << "Unable to click at by mouse, clickAt returned non-zero value";
      return static_cast<int>(result);
    }

    //wait(50);
  } else {
    LOG(WARN) << "Unable to get location of clicked element";
  }

  return status_code;
}
void GenerationWidget::mousePressEvent(QMouseEvent* e)
{
    const QPoint& clickPos = e->pos() - mDestRect.topLeft();
    emit clickAt(QPointF((qreal)clickPos.x() / mDestRect.width(), (qreal)clickPos.y() / mDestRect.height()));
}