(Qt): invent FStopMouseEventsProcessing flag to notify whether mouse events should be stoped at widget of passed to parent

git-svn-id: trunk@11647 -
This commit is contained in:
paul 2007-07-27 18:42:34 +00:00
parent 5f5b46fe5d
commit 0892924a1c
2 changed files with 42 additions and 11 deletions

View File

@ -53,6 +53,7 @@ type
FProps: TStringList; FProps: TStringList;
FPaintData: TPaintData; FPaintData: TPaintData;
FCentralWidget: QWidgetH; FCentralWidget: QWidgetH;
FStopMouseEventsProcessing: Boolean; // widget stop processing of mouse events
function GetProps(const AnIndex: String): pointer; function GetProps(const AnIndex: String): pointer;
function GetWidget: QWidgetH; function GetWidget: QWidgetH;
@ -130,6 +131,7 @@ type
property Props[AnIndex:String]:pointer read GetProps write SetProps; property Props[AnIndex:String]:pointer read GetProps write SetProps;
property PaintData: TPaintData read FPaintData write FPaintData; property PaintData: TPaintData read FPaintData write FPaintData;
property Widget: QWidgetH read GetWidget write SetWidget; property Widget: QWidgetH read GetWidget write SetWidget;
property StopMouseEventsProcessing: Boolean read FStopMouseEventsProcessing;
end; end;
{ TQtFrame } { TQtFrame }
@ -794,6 +796,7 @@ begin
// Initializes the properties // Initializes the properties
FProps := NiL; FProps := NiL;
LCLObject := AWinControl; LCLObject := AWinControl;
FStopMouseEventsProcessing := False;
// Creates the widget // Creates the widget
Widget := CreateWidget(AParams); Widget := CreateWidget(AParams);
@ -832,6 +835,7 @@ constructor TQtWidget.CreatePage(const AWinControl: TWinControl;
begin begin
// Initializes the properties // Initializes the properties
LCLObject := AWinControl; LCLObject := AWinControl;
FStopMouseEventsProcessing := True;
// Creates the widget // Creates the widget
Widget := QWidget_create; Widget := QWidget_create;
@ -1064,18 +1068,35 @@ begin
releaseMouse; releaseMouse;
end; end;
QEventHoverEnter : SlotHover(Event); QEventHoverEnter,
QEventHoverLeave : SlotHover(Event); QEventHoverLeave,
QEventHoverMove : SlotHover(Event); QEventHoverMove:
begin
SlotHover(Event);
Result := StopMouseEventsProcessing;
end;
QEventKeyPress: SlotKey(Event); QEventKeyPress: SlotKey(Event);
QEventKeyRelease: SlotKey(Event); QEventKeyRelease: SlotKey(Event);
QEventLeave: SlotMouseEnter(Event); QEventLeave: SlotMouseEnter(Event);
QEventMouseButtonPress: SlotMouse(Event);
QEventMouseButtonRelease: SlotMouse(Event); QEventMouseButtonPress,
QEventMouseButtonDblClick: SlotMouse(Event); QEventMouseButtonRelease,
QEventMouseMove: SlotMouseMove(Event); QEventMouseButtonDblClick:
QEventWheel: SlotMouseWheel(Event); begin
SlotMouse(Event);
Result := StopMouseEventsProcessing;
end;
QEventMouseMove:
begin
SlotMouseMove(Event);
Result := StopMouseEventsProcessing;
end;
QEventWheel:
begin
SlotMouseWheel(Event);
Result := StopMouseEventsProcessing;
end;
QEventResize: SlotResize; QEventResize: SlotResize;
QEventPaint: SlotPaint(Event); QEventPaint: SlotPaint(Event);
QEventContextMenu: SlotContextMenu; QEventContextMenu: SlotContextMenu;
@ -2511,6 +2532,7 @@ begin
QLayout_addWidget(LayoutWidget, FCentralWidget); QLayout_addWidget(LayoutWidget, FCentralWidget);
QWidget_setLayout(Result, QLayoutH(LayoutWidget)); QWidget_setLayout(Result, QLayoutH(LayoutWidget));
end; end;
FStopMouseEventsProcessing := True;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -3012,6 +3034,7 @@ begin
Parent := TQtWidget(LCLObject.Parent.Handle).GetContainerWidget; Parent := TQtWidget(LCLObject.Parent.Handle).GetContainerWidget;
Result := QFrame_create(Parent); Result := QFrame_create(Parent);
QWidget_setAutoFillBackground(Result, True); QWidget_setAutoFillBackground(Result, True);
FStopMouseEventsProcessing := True;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -3099,6 +3122,7 @@ begin
Parent := TQtWidget(LCLObject.Parent.Handle).GetContainerWidget; Parent := TQtWidget(LCLObject.Parent.Handle).GetContainerWidget;
Result := QFrame_create(Parent); Result := QFrame_create(Parent);
//QWidget_setAutoFillBackground(Result, True); //QWidget_setAutoFillBackground(Result, True);
FStopMouseEventsProcessing := True;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -5403,6 +5427,7 @@ begin
FViewPortWidget := NiL; FViewPortWidget := NiL;
Parent := TQtWidget(LCLObject.Parent.Handle).GetContainerWidget; Parent := TQtWidget(LCLObject.Parent.Handle).GetContainerWidget;
Result := QScrollArea_create(Parent); Result := QScrollArea_create(Parent);
FStopMouseEventsProcessing := True;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------

View File

@ -1695,14 +1695,14 @@ function TQtWidgetSet.GetCapture: HWND;
var var
w: QWidgetH; w: QWidgetH;
begin begin
{$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI GetCapture]');
{$endif}
w := QWidget_mouseGrabber(); w := QWidget_mouseGrabber();
if w <> nil then if w <> nil then
Result := HWND(QtObjectFromWidgetH(w)) Result := HWND(QtObjectFromWidgetH(w))
else else
Result := 0; Result := 0;
{$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI GetCapture] Capture = ', Result);
{$endif}
end; end;
function TQtWidgetSet.GetCaretPos(var lpPoint: TPoint): Boolean; function TQtWidgetSet.GetCaretPos(var lpPoint: TPoint): Boolean;
@ -3571,6 +3571,9 @@ begin
Result := w <> nil; Result := w <> nil;
if Result then if Result then
w.releaseMouse(); w.releaseMouse();
{$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI ReleaseCapture] Capture = ', THandle(w));
{$endif}
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -3946,6 +3949,9 @@ begin
ReleaseCapture; ReleaseCapture;
if AHandle <> 0 then if AHandle <> 0 then
TQtWidget(AHandle).grabMouse(); TQtWidget(AHandle).grabMouse();
{$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI SetCapture] Capture = ', Result, ' New capture = ', AHandle);
{$endif}
FillChar(Message, SizeOf(Message), 0); FillChar(Message, SizeOf(Message), 0);
Message.msg := LM_CAPTURECHANGED; Message.msg := LM_CAPTURECHANGED;
Message.wParam := 0; Message.wParam := 0;