mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 23:34:06 +00:00
fix:single click to select word does not work properly
This commit is contained in:
parent
93f75d1cf5
commit
4d648aca09
|
@ -73,12 +73,10 @@ bool ArticleWebView::eventFilter(QObject *obj, QEvent *ev)
|
|||
if (ev->type() == QEvent::Wheel) {
|
||||
QWheelEvent *pe = static_cast<QWheelEvent *>(ev);
|
||||
wheelEvent(pe);
|
||||
//return true;
|
||||
}
|
||||
if (ev->type() == QEvent::FocusIn) {
|
||||
QFocusEvent *pe = static_cast<QFocusEvent *>(ev);
|
||||
focusInEvent(pe);
|
||||
//return true;
|
||||
}
|
||||
|
||||
return QWebEngineView::eventFilter(obj, ev);
|
||||
|
@ -99,13 +97,14 @@ void ArticleWebView::singleClickAction(QObject* obj, QMouseEvent * event )
|
|||
|
||||
if (selectionBySingleClick) {
|
||||
findText(""); // clear the selection first, if any
|
||||
//send dbl click event twice? send one time seems not work .weird really. need further investigate.
|
||||
sendCustomMouseEvent(obj, QEvent::MouseButtonDblClick, event);
|
||||
sendCustomMouseEvent(obj, QEvent::MouseButtonDblClick, event);
|
||||
sendCustomMouseEvent(obj, QEvent::MouseButtonRelease, event);
|
||||
}
|
||||
}
|
||||
|
||||
void ArticleWebView::sendCustomMouseEvent(QObject* obj,QEvent::Type type,QMouseEvent * event){
|
||||
QMouseEvent ev( QEvent::MouseButtonDblClick,mapFromGlobal(QCursor::pos()),mapFromGlobal(QCursor::pos()),QCursor::pos(), Qt::LeftButton, Qt::LeftButton, event->modifiers(), Qt::MouseEventSynthesizedByApplication );
|
||||
QMouseEvent ev( type,mapFromGlobal(QCursor::pos()),mapFromGlobal(QCursor::pos()),QCursor::pos(), Qt::LeftButton, Qt::LeftButton, event->modifiers(), Qt::MouseEventSynthesizedByApplication );
|
||||
QApplication::sendEvent(obj, &ev );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue