mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 09:36:10 +02:00
Qt: implemented csCaptureMouse flag.
git-svn-id: trunk@27284 -
This commit is contained in:
parent
97eddada84
commit
9a31e1e0ce
@ -173,7 +173,7 @@ type
|
|||||||
function SlotKey(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
function SlotKey(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||||
function SlotMouse(Sender: QObjectH; Event: QEventH): Boolean; virtual; cdecl;
|
function SlotMouse(Sender: QObjectH; Event: QEventH): Boolean; virtual; cdecl;
|
||||||
procedure SlotNCMouse(Sender: QObjectH; Event: QEventH); cdecl;
|
procedure SlotNCMouse(Sender: QObjectH; Event: QEventH); cdecl;
|
||||||
procedure SlotMouseEnter(Sender: QObjectH; Event: QEventH); cdecl;
|
function SlotMouseEnter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||||
function SlotMouseMove(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
function SlotMouseMove(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||||
procedure SlotMouseWheel(Sender: QObjectH; Event: QEventH); cdecl;
|
procedure SlotMouseWheel(Sender: QObjectH; Event: QEventH); cdecl;
|
||||||
procedure SlotMove(Event: QEventH); cdecl;
|
procedure SlotMove(Event: QEventH); cdecl;
|
||||||
@ -2056,7 +2056,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
QEventDestroy: SlotDestroy;
|
QEventDestroy: SlotDestroy;
|
||||||
QEventEnter,
|
QEventEnter,
|
||||||
QEventLeave: SlotMouseEnter(Sender, Event);
|
QEventLeave: Result := SlotMouseEnter(Sender, Event);
|
||||||
|
|
||||||
QEventHoverEnter,
|
QEventHoverEnter,
|
||||||
QEventHoverLeave,
|
QEventHoverLeave,
|
||||||
@ -2745,10 +2745,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TQtWidget.SlotMouseEnter(Sender: QObjectH; Event: QEventH); cdecl;
|
function TQtWidget.SlotMouseEnter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||||
var
|
var
|
||||||
Msg: TLMessage;
|
Msg: TLMessage;
|
||||||
begin
|
begin
|
||||||
|
Result := False;
|
||||||
FillChar(Msg, SizeOf(Msg), #0);
|
FillChar(Msg, SizeOf(Msg), #0);
|
||||||
case QEvent_type(Event) of
|
case QEvent_type(Event) of
|
||||||
QEventEnter: Msg.Msg := CM_MOUSEENTER;
|
QEventEnter: Msg.Msg := CM_MOUSEENTER;
|
||||||
@ -2797,10 +2798,70 @@ function TQtWidget.SlotMouseMove(Sender: QObjectH; Event: QEventH): Boolean; cde
|
|||||||
var
|
var
|
||||||
Msg: TLMMouseMove;
|
Msg: TLMMouseMove;
|
||||||
MousePos: TQtPoint;
|
MousePos: TQtPoint;
|
||||||
|
GlobPos: TQtPoint;
|
||||||
|
R: TRect;
|
||||||
|
P: TPoint;
|
||||||
|
NewEvent: QEventH;
|
||||||
|
W: QWidgetH;
|
||||||
|
FrameBorder: Integer;
|
||||||
|
TitleBarHeight: Integer;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
if not CanSendLCLMessage then
|
if not CanSendLCLMessage then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
|
if not (csCaptureMouse in LCLObject.ControlStyle) and
|
||||||
|
not QWidget_isWindow(Widget) 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);
|
||||||
|
|
||||||
|
if W <> nil then
|
||||||
|
begin
|
||||||
|
QWidget_frameGeometry(W, @R);
|
||||||
|
|
||||||
|
// exclude borders from frame
|
||||||
|
FrameBorder := QStyle_pixelMetric(QApplication_style(),
|
||||||
|
QStylePM_DefaultFrameWidth, nil, W);
|
||||||
|
TitleBarHeight := QStyle_pixelMetric(QApplication_style(),
|
||||||
|
QStylePM_TitleBarHeight, nil, W);
|
||||||
|
|
||||||
|
inc(R.Left, FrameBorder);
|
||||||
|
inc(R.Top, TitleBarHeight);
|
||||||
|
dec(R.Right, FrameBorder);
|
||||||
|
dec(R.Bottom, FrameBorder);
|
||||||
|
|
||||||
|
P := Point(GlobPos.X, GlobPos.Y);
|
||||||
|
if not PtInRect(R, P) then
|
||||||
|
MousePos := QtPoint(-1, -1);
|
||||||
|
|
||||||
|
if not QWidget_underMouse(Widget) then
|
||||||
|
begin
|
||||||
|
if (MousePos.X >= 0) and (MousePos.Y >= 0) then
|
||||||
|
begin
|
||||||
|
QWidget_setAttribute(Widget, QtWA_UnderMouse, True);
|
||||||
|
NewEvent := QEvent_create(QEventEnter);
|
||||||
|
QCoreApplication_postEvent(Widget, NewEvent, 100);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if not (csCaptureMouse in LCLObject.ControlStyle) and
|
||||||
|
(QApplication_mouseButtons() <> QtNoButton) and
|
||||||
|
((MousePos.X < 0) or (MousePos.Y < 0)) then
|
||||||
|
begin
|
||||||
|
if not QWidget_underMouse(Widget) then
|
||||||
|
exit;
|
||||||
|
setCursor(FDefaultCursor);
|
||||||
|
NewEvent := QEvent_create(QEventLeave);
|
||||||
|
QCoreApplication_postEvent(Widget, NewEvent, 100);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
FillChar(Msg, SizeOf(Msg), #0);
|
FillChar(Msg, SizeOf(Msg), #0);
|
||||||
|
|
||||||
MousePos := QMouseEvent_pos(QMouseEventH(Event))^;
|
MousePos := QMouseEvent_pos(QMouseEventH(Event))^;
|
||||||
|
Loading…
Reference in New Issue
Block a user