Qt,Qt5,Qt6: fixed buggy mouse capture with TSpinEdit, TFloatSpinEdit. issue #40725

(cherry picked from commit 27bc023a87)
This commit is contained in:
Željan Rikalo 2024-01-24 18:12:05 +01:00
parent ea073bee6b
commit b086f9dfa0
3 changed files with 39 additions and 3 deletions

View File

@ -1104,6 +1104,7 @@ type
// parts // parts
FLineEdit: QLineEditH; FLineEdit: QLineEditH;
FTextChangedByValueChanged: Boolean; FTextChangedByValueChanged: Boolean;
FMouseCaptureFix: boolean; {issue #40725}
function GetLineEdit: QLineEditH; function GetLineEdit: QLineEditH;
function LineEditEventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; function LineEditEventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
protected protected
@ -11776,10 +11777,11 @@ end;
procedure TQtAbstractSpinBox.grabMouse; procedure TQtAbstractSpinBox.grabMouse;
begin begin
if Assigned(LCLObject) and not (csDesigning in LCLObject.ComponentState) if Assigned(LCLObject) and not (csDesigning in LCLObject.ComponentState)
and Assigned(LineEdit) then and Assigned(LineEdit) and not FMouseCaptureFix then
QWidget_grabMouse(LineEdit) QWidget_grabMouse(LineEdit)
else else
inherited grabMouse; inherited grabMouse;
FMouseCaptureFix := False;
end; end;
procedure TQtAbstractSpinBox.setAlignment(const AAlignment: QtAlignment); procedure TQtAbstractSpinBox.setAlignment(const AAlignment: QtAlignment);
@ -11850,6 +11852,16 @@ begin
(QKeyEvent_modifiers(QKeyEventH(Event)) = QtNoModifier) (QKeyEvent_modifiers(QKeyEventH(Event)) = QtNoModifier)
else else
IsDeleteKey := False; IsDeleteKey := False;
{issue #40725}
if (QEvent_type(Event) >= QEventMouseButtonPress) and (QEvent_type(Event) <= QEventMouseMove) then
begin
if (QEvent_type(Event) = QEventMouseButtonPress) and (LineEdit <> Sender) then
FMouseCaptureFix := True
else
FMouseCaptureFix := False;
end;
Result := inherited EventFilter(Sender, Event); Result := inherited EventFilter(Sender, Event);
{we must pass delete key to qt, qabstractspinbox doesn't like what we do} {we must pass delete key to qt, qabstractspinbox doesn't like what we do}
if IsDeleteKey then if IsDeleteKey then

View File

@ -1121,6 +1121,7 @@ type
// parts // parts
FLineEdit: QLineEditH; FLineEdit: QLineEditH;
FTextChangedByValueChanged: Boolean; FTextChangedByValueChanged: Boolean;
FMouseCaptureFix: boolean; {issue #40725}
function GetLineEdit: QLineEditH; function GetLineEdit: QLineEditH;
function LineEditEventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; function LineEditEventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
protected protected
@ -12045,10 +12046,11 @@ end;
procedure TQtAbstractSpinBox.grabMouse; procedure TQtAbstractSpinBox.grabMouse;
begin begin
if Assigned(LCLObject) and not (csDesigning in LCLObject.ComponentState) if Assigned(LCLObject) and not (csDesigning in LCLObject.ComponentState)
and Assigned(LineEdit) then and Assigned(LineEdit) and not FMouseCaptureFix then
QWidget_grabMouse(LineEdit) QWidget_grabMouse(LineEdit)
else else
inherited grabMouse; inherited grabMouse;
FMouseCaptureFix := False;
end; end;
procedure TQtAbstractSpinBox.setAlignment(const AAlignment: QtAlignment); procedure TQtAbstractSpinBox.setAlignment(const AAlignment: QtAlignment);
@ -12119,6 +12121,16 @@ begin
(QKeyEvent_modifiers(QKeyEventH(Event)) = QtNoModifier) (QKeyEvent_modifiers(QKeyEventH(Event)) = QtNoModifier)
else else
IsDeleteKey := False; IsDeleteKey := False;
{issue #40725}
if (QEvent_type(Event) >= QEventMouseButtonPress) and (QEvent_type(Event) <= QEventMouseMove) then
begin
if (QEvent_type(Event) = QEventMouseButtonPress) and (LineEdit <> Sender) then
FMouseCaptureFix := True
else
FMouseCaptureFix := False;
end;
Result := inherited EventFilter(Sender, Event); Result := inherited EventFilter(Sender, Event);
{we must pass delete key to qt, qabstractspinbox doesn't like what we do} {we must pass delete key to qt, qabstractspinbox doesn't like what we do}
if IsDeleteKey then if IsDeleteKey then

View File

@ -1122,6 +1122,7 @@ type
// parts // parts
FLineEdit: QLineEditH; FLineEdit: QLineEditH;
FTextChangedByValueChanged: Boolean; FTextChangedByValueChanged: Boolean;
FMouseCaptureFix: boolean; {issue #40725}
function GetLineEdit: QLineEditH; function GetLineEdit: QLineEditH;
function LineEditEventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; function LineEditEventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
protected protected
@ -12072,10 +12073,11 @@ end;
procedure TQtAbstractSpinBox.grabMouse; procedure TQtAbstractSpinBox.grabMouse;
begin begin
if Assigned(LCLObject) and not (csDesigning in LCLObject.ComponentState) if Assigned(LCLObject) and not (csDesigning in LCLObject.ComponentState)
and Assigned(LineEdit) then and Assigned(LineEdit) and not FMouseCaptureFix then
QWidget_grabMouse(LineEdit) QWidget_grabMouse(LineEdit)
else else
inherited grabMouse; inherited grabMouse;
FMouseCaptureFix := False;
end; end;
procedure TQtAbstractSpinBox.setAlignment(const AAlignment: QtAlignment); procedure TQtAbstractSpinBox.setAlignment(const AAlignment: QtAlignment);
@ -12146,6 +12148,16 @@ begin
(QKeyEvent_modifiers(QKeyEventH(Event)) = QtNoModifier) (QKeyEvent_modifiers(QKeyEventH(Event)) = QtNoModifier)
else else
IsDeleteKey := False; IsDeleteKey := False;
{issue #40725}
if (QEvent_type(Event) >= QEventMouseButtonPress) and (QEvent_type(Event) <= QEventMouseMove) then
begin
if (QEvent_type(Event) = QEventMouseButtonPress) and (LineEdit <> Sender) then
FMouseCaptureFix := True
else
FMouseCaptureFix := False;
end;
Result := inherited EventFilter(Sender, Event); Result := inherited EventFilter(Sender, Event);
{we must pass delete key to qt, qabstractspinbox doesn't like what we do} {we must pass delete key to qt, qabstractspinbox doesn't like what we do}
if IsDeleteKey then if IsDeleteKey then