void HoveringButtonsController::ForwardMouseClickEvent(float x, float y) { // To widgetspace float x_widgetspace = x*(float)this->width(); float y_widgetspace = y*(float)this->height(); QPoint pos(x_widgetspace,y_widgetspace); QMouseEvent e(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QApplication::sendEvent(this, &e); // Iterate through buttons and check if they are pressed for(int i = 0; i< layout()->count();i++) { QLayoutItem* item = layout()->itemAt(i); QAbstractButton *button = dynamic_cast<QAbstractButton*>(item->widget()); if(button) { if(button->rect().contains(button->mapFromParent(pos))) { QMouseEvent e(QEvent::MouseButtonPress, pos - button->pos(),pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QApplication::sendEvent(button, &e); } } } }
void TaskView::keyPressEvent(QKeyEvent* ke) { if (ActiveCtrl && ActiveDialog) { if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) { // get all buttons of the complete task dialog QList<QPushButton*> list = this->findChildren<QPushButton*>(); for (int i=0; i<list.size(); ++i) { QPushButton *pb = list.at(i); if (pb->isDefault() && pb->isVisible()) { if (pb->isEnabled()) { #if defined(FC_OS_MACOSX) // #0001354: Crash on using Enter-Key for confirmation of chamfer or fillet entries QPoint pos = QCursor::pos(); QCursor::setPos(pb->parentWidget()->mapToGlobal(pb->pos())); #endif pb->click(); #if defined(FC_OS_MACOSX) QCursor::setPos(pos); #endif } return; } } } else if (ke->key() == Qt::Key_Escape) { // get only the buttons of the button box QDialogButtonBox* box = ActiveCtrl->standardButtons(); QList<QAbstractButton*> list = box->buttons(); for (int i=0; i<list.size(); ++i) { QAbstractButton *pb = list.at(i); if (box->buttonRole(pb) == QDialogButtonBox::RejectRole) { if (pb->isEnabled()) { #if defined(FC_OS_MACOSX) // #0001354: Crash on using Enter-Key for confirmation of chamfer or fillet entries QPoint pos = QCursor::pos(); QCursor::setPos(pb->parentWidget()->mapToGlobal(pb->pos())); #endif pb->click(); #if defined(FC_OS_MACOSX) QCursor::setPos(pos); #endif } return; } } } } else { QScrollArea::keyPressEvent(ke); } }