(Qt): fixing GetCapture, SetCapture, ReleaseCapture problems if qt sets capture to sub-widget of complex widget

git-svn-id: trunk@11685 -
This commit is contained in:
paul 2007-07-31 11:13:26 +00:00
parent d8ebcebd22
commit a0afe010c2
2 changed files with 22 additions and 11 deletions

View File

@ -1745,8 +1745,13 @@ begin
end;
procedure TQtWidget.releaseMouse;
var
AGrabWidget: QWidgetH;
begin
QWidget_releaseMouse(Widget);
// capture widget can be one of childs of Widget if Widget is complex control
// so better to look for current Capture widget to release it instead of pass Widget as argument
AGrabWidget := QWidget_mouseGrabber();
QWidget_releaseMouse(AGrabWidget);
end;
procedure TQtWidget.setEnabled(p1: Boolean);

View File

@ -1704,10 +1704,24 @@ end;
function TQtWidgetSet.GetCapture: HWND;
var
w: QWidgetH;
Widget: TQtWidget;
begin
w := QWidget_mouseGrabber();
if w <> nil then
Result := HWND(QtObjectFromWidgetH(w))
begin
// Capture widget can be child of complex control. In any case we should return TQtWidget as result.
// So we will look for parent while not found apropriate LCL handle.
repeat
Widget := QtObjectFromWidgetH(w);
if Widget = nil then
begin
w := QWidget_parentWidget(w);
if w = nil then
break;
end;
until Widget <> nil;
Result := HWND(Widget);
end
else
Result := 0;
{$ifdef VerboseQtWinAPI}
@ -3917,15 +3931,7 @@ begin
if Result <> 0 then
ReleaseCapture;
if AHandle <> 0 then
begin
{TODO: freezing workaround, ttabsheet kills mouse at all (X & app),
when we click onto empty tabsheet.
don't know for others , so it's ifdef-ed for linux}
{$ifdef linux}
if not (TQtWidget(AHandle).LCLObject.InheritsFrom(TCustomPage)) then
{$endif}
TQtWidget(AHandle).grabMouse();
end;
TQtWidget(AHandle).grabMouse();
{$ifdef VerboseQtWinAPI}
WriteLn('[WinAPI SetCapture] Capture = ', Result, ' New capture = ', AHandle);
{$endif}