mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 01:16:01 +02:00
qt: don't send LM_CHANGE messages when changing State of TRadioButton and TCheckBox programatically. Use Toggled signal instead of Clicked to notify of changes in TRadioButton. Part of 0017139 and 0017104
git-svn-id: trunk@27054 -
This commit is contained in:
parent
1aa796b724
commit
e50914e4bf
@ -460,7 +460,6 @@ type
|
||||
procedure SignalReleased; cdecl;
|
||||
procedure SignalClicked(Checked: Boolean = False); cdecl;
|
||||
procedure SignalClicked2; cdecl;
|
||||
procedure SignalToggled(Checked: Boolean); cdecl;
|
||||
end;
|
||||
|
||||
{ TQtPushButton }
|
||||
@ -571,12 +570,13 @@ type
|
||||
|
||||
TQtRadioButton = class(TQtAbstractButton)
|
||||
private
|
||||
FClickedHook: QAbstractButton_hookH;
|
||||
FToggledHook: QAbstractButton_hookH;
|
||||
protected
|
||||
function CreateWidget(const AParams: TCreateParams):QWidgetH; override;
|
||||
public
|
||||
procedure AttachEvents; override;
|
||||
procedure DetachEvents; override;
|
||||
procedure SignalToggled(Checked: Boolean); cdecl;
|
||||
function EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl; override;
|
||||
end;
|
||||
|
||||
@ -4360,17 +4360,6 @@ begin
|
||||
DeliverMessage(Msg);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: TQtAbstractButton.SignalToggled
|
||||
Params: None
|
||||
Returns: Nothing
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TQtAbstractButton.SignalToggled(Checked: Boolean); cdecl;
|
||||
begin
|
||||
{use this for TToggleButton }
|
||||
end;
|
||||
|
||||
|
||||
{ TQtPushButton }
|
||||
|
||||
function TQtPushButton.CreateWidget(const AParams: TCreateParams): QWidgetH;
|
||||
@ -5060,9 +5049,12 @@ procedure TQtCheckBox.signalStateChanged(p1: Integer); cdecl;
|
||||
var
|
||||
Msg: TLMessage;
|
||||
begin
|
||||
FillChar(Msg, SizeOf(Msg), #0);
|
||||
Msg.Msg := LM_CHANGED;
|
||||
DeliverMessage(Msg);
|
||||
if not InUpdate then
|
||||
begin
|
||||
FillChar(Msg, SizeOf(Msg), #0);
|
||||
Msg.Msg := LM_CHANGED;
|
||||
DeliverMessage(Msg);
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TQtRadioButton }
|
||||
@ -5088,19 +5080,29 @@ end;
|
||||
procedure TQtRadioButton.AttachEvents;
|
||||
begin
|
||||
inherited AttachEvents;
|
||||
FClickedHook := QAbstractButton_hook_create(Widget);
|
||||
|
||||
QAbstractButton_hook_hook_clicked(FClickedHook, @SignalClicked);
|
||||
FToggledHook := QAbstractButton_hook_create(Widget);
|
||||
QAbstractButton_hook_hook_toggled(FToggledHook, @SignalToggled);
|
||||
end;
|
||||
|
||||
procedure TQtRadioButton.DetachEvents;
|
||||
begin
|
||||
QAbstractButton_hook_destroy(FClickedHook);
|
||||
QAbstractButton_hook_destroy(FToggledHook);
|
||||
inherited DetachEvents;
|
||||
end;
|
||||
|
||||
function TQtRadioButton.EventFilter(Sender: QObjectH; Event: QEventH): Boolean;
|
||||
cdecl;
|
||||
procedure TQtRadioButton.SignalToggled(Checked: Boolean); cdecl;
|
||||
var
|
||||
Msg: TLMessage;
|
||||
begin
|
||||
if not InUpdate then
|
||||
begin
|
||||
FillChar(Msg, SizeOf(Msg), #0);
|
||||
Msg.Msg := LM_CHANGED;
|
||||
DeliverMessage(Msg);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TQtRadioButton.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
|
||||
begin
|
||||
Result := inherited EventFilter(Sender, Event);
|
||||
if (LCLObject <> nil) and
|
||||
@ -5110,7 +5112,7 @@ begin
|
||||
(QKeyEvent_key(QKeyEventH(Event)) = QtKey_Space) and
|
||||
isChecked))
|
||||
then
|
||||
Result := not (LCLObject.Parent is TRadioGroup);
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
{ TQtGroupBox }
|
||||
|
@ -1060,13 +1060,19 @@ end;
|
||||
Returns: Nothing
|
||||
------------------------------------------------------------------------------}
|
||||
class procedure TQtWSCustomCheckBox.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState);
|
||||
var
|
||||
QtCheckBox: TQtCheckBox;
|
||||
begin
|
||||
//enclose the call between Begin/EndUpdate to avoid send LM_CHANGE message
|
||||
QtCheckBox := TQtCheckBox(ACustomCheckBox.Handle);
|
||||
QtCheckBox.BeginUpdate;
|
||||
case NewState of
|
||||
cbGrayed: TQtCheckBox(ACustomCheckBox.Handle).setCheckState(QtPartiallyChecked);
|
||||
cbChecked: TQtCheckBox(ACustomCheckBox.Handle).setCheckState(QtChecked);
|
||||
cbGrayed: QtCheckBox.setCheckState(QtPartiallyChecked);
|
||||
cbChecked: QtCheckBox.setCheckState(QtChecked);
|
||||
else
|
||||
TQtCheckBox(ACustomCheckBox.Handle).setCheckState(QtUnchecked);
|
||||
QtCheckBox.setCheckState(QtUnchecked);
|
||||
end;
|
||||
QtCheckBox.EndUpdate;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -1120,8 +1126,14 @@ end;
|
||||
Sets the state of the control
|
||||
------------------------------------------------------------------------------}
|
||||
class procedure TQtWSRadioButton.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState);
|
||||
var
|
||||
QtRadioButton: TQtRadioButton;
|
||||
begin
|
||||
TQtRadioButton(ACustomCheckBox.Handle).setChecked(NewState = cbChecked);
|
||||
//enclose the call between Begin/EndUpdate to avoid send LM_CHANGE message
|
||||
QtRadioButton := TQtRadioButton(ACustomCheckBox.Handle);
|
||||
QtRadioButton.BeginUpdate;
|
||||
QtRadioButton.setChecked(NewState = cbChecked);
|
||||
QtRadioButton.EndUpdate;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user