mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-05-30 02:49:12 -04:00
fix: Add mouse propogation to qml chat in qquickwidget
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "ChatWidget.hpp"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMouseEvent>
|
||||
#include <QQmlContext>
|
||||
#include <QQmlEngine>
|
||||
#include <QQuickItem>
|
||||
@@ -38,6 +39,8 @@ ChatWidget::ChatWidget(
|
||||
setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
setAttribute(Qt::WA_NoMousePropagation, true);
|
||||
|
||||
if (registerOwnContext) {
|
||||
auto ideContext = new Core::IContext{this};
|
||||
ideContext->setWidget(this);
|
||||
@@ -53,6 +56,14 @@ void ChatWidget::focusInEvent(QFocusEvent *event)
|
||||
QMetaObject::invokeMethod(rootObject(), "focusInput");
|
||||
}
|
||||
|
||||
void ChatWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!hasFocus())
|
||||
setFocus(Qt::MouseFocusReason);
|
||||
|
||||
QQuickWidget::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void ChatWidget::clear()
|
||||
{
|
||||
QMetaObject::invokeMethod(rootObject(), "clearChat");
|
||||
|
||||
@@ -42,6 +42,7 @@ signals:
|
||||
|
||||
protected:
|
||||
void focusInEvent(QFocusEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
};
|
||||
|
||||
} // namespace QodeAssist::Chat
|
||||
|
||||
Reference in New Issue
Block a user