mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 23:49:36 +02:00
Qt: bit refactored viewportEventFilter of TQtCustomControl, use Sender in mouse move, not Widget.
git-svn-id: trunk@38366 -
This commit is contained in:
parent
4c7a01b629
commit
87ed4c7d57
@ -3412,20 +3412,24 @@ var
|
||||
W: QWidgetH;
|
||||
FrameBorder: Integer;
|
||||
TitleBarHeight: Integer;
|
||||
SenderWidget: QWidgetH;
|
||||
begin
|
||||
Result := False;
|
||||
if not CanSendLCLMessage then
|
||||
if not CanSendLCLMessage or (Sender = nil) or
|
||||
not QObject_isWidgetType(Sender) then
|
||||
Exit(True);
|
||||
|
||||
SenderWidget := QWidgetH(Sender);
|
||||
|
||||
if not (csCaptureMouse in LCLObject.ControlStyle) and
|
||||
not QWidget_isWindow(Widget) and
|
||||
not QWidget_isWindow(SenderWidget) and
|
||||
not DragManager.IsDragging then
|
||||
begin
|
||||
MousePos := QMouseEvent_pos(QMouseEventH(Event))^;
|
||||
GlobPos := QMouseEvent_globalPos(QMouseEventH(Event))^;
|
||||
|
||||
// get parent form, so check if mouse is out of parent form first.
|
||||
W := QWidget_window(Widget);
|
||||
W := QWidget_window(SenderWidget);
|
||||
|
||||
if W <> nil then
|
||||
begin
|
||||
@ -3444,13 +3448,13 @@ begin
|
||||
if not PtInRect(R, P) then
|
||||
MousePos := QtPoint(-1, -1);
|
||||
|
||||
if not QWidget_underMouse(Widget) then
|
||||
if not QWidget_underMouse(SenderWidget) then
|
||||
begin
|
||||
if (MousePos.X >= 0) and (MousePos.Y >= 0) then
|
||||
begin
|
||||
QWidget_setAttribute(Widget, QtWA_UnderMouse, True);
|
||||
QWidget_setAttribute(SenderWidget, QtWA_UnderMouse, True);
|
||||
NewEvent := QEvent_create(QEventEnter);
|
||||
QCoreApplication_postEvent(Widget, NewEvent, 100);
|
||||
QCoreApplication_postEvent(SenderWidget, NewEvent, 100);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -3460,11 +3464,11 @@ begin
|
||||
(((MousePos.X < 0) or (MousePos.Y < 0)) or
|
||||
((MousePos.X > getWidth) or (MousePos.Y > getHeight))) then
|
||||
begin
|
||||
if not QWidget_underMouse(Widget) then
|
||||
if not QWidget_underMouse(SenderWidget) then
|
||||
exit;
|
||||
setCursor(FDefaultCursor);
|
||||
NewEvent := QEvent_create(QEventLeave);
|
||||
QCoreApplication_postEvent(Widget, NewEvent, 100);
|
||||
QCoreApplication_postEvent(SenderWidget, NewEvent, 100);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
@ -3477,14 +3481,14 @@ begin
|
||||
Msg.XPos := SmallInt(MousePos.X);
|
||||
Msg.YPos := SmallInt(MousePos.Y);
|
||||
|
||||
Msg.Keys := QtButtonsToLCLButtons(QmouseEvent_Buttons(QMouseEventH(Event)))
|
||||
Msg.Keys := QtButtonsToLCLButtons(QMouseEvent_Buttons(QMouseEventH(Event)))
|
||||
or QtKeyModifiersToKeyState(QInputEvent_modifiers(QInputEventH(Event)), False, nil);
|
||||
|
||||
Msg.Msg := LM_MOUSEMOVE;
|
||||
|
||||
NotifyApplicationUserInput(LCLObject, Msg.Msg);
|
||||
DeliverMessage(Msg);
|
||||
SetNoMousePropagation(QWidgetH(Sender), True);
|
||||
SetNoMousePropagation(SenderWidget, True);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -14733,7 +14737,8 @@ begin
|
||||
MouseEventTyp := (QEvent_type(Event) = QEventMouseButtonPress) or
|
||||
(QEvent_type(Event) = QEventMouseButtonRelease) or
|
||||
(QEvent_type(Event) = QEventMouseButtonDblClick) or
|
||||
(QEvent_type(Event) = QEventWheel);
|
||||
(QEvent_type(Event) = QEventWheel) or
|
||||
(QEvent_type(Event) = QEventMouseMove);
|
||||
|
||||
if (QEvent_type(Event) = QEventWheel) and
|
||||
(QtVersionMajor = 4) and (QtVersionMinor > 6) then
|
||||
@ -14741,7 +14746,8 @@ begin
|
||||
|
||||
retval^ := True;
|
||||
|
||||
Viewport.EventFilter(ViewPort.Widget, Event);
|
||||
if FViewPortWidget <> nil then
|
||||
Viewport.EventFilter(ViewPortWidget, Event);
|
||||
|
||||
// do not allow qt to call notifications on user input events (mouse)
|
||||
// otherwise we can crash since our object maybe does not exist
|
||||
|
Loading…
Reference in New Issue
Block a user