mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-07 20:41:37 +02:00
cocoa: clear sibling radio button states when one is changed
git-svn-id: trunk@34616 -
This commit is contained in:
parent
9221f3df77
commit
7f9a727d41
@ -24,6 +24,7 @@ unit CocoaWSStdCtrls;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$modeswitch objectivec1}
|
||||
{$modeswitch objectivec2}
|
||||
|
||||
interface
|
||||
|
||||
@ -185,6 +186,13 @@ type
|
||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||
end;
|
||||
|
||||
{ TLCLRadioButtonCallback }
|
||||
|
||||
TLCLRadioButtonCallback = class(TLCLCheckBoxCallback)
|
||||
public
|
||||
procedure ButtonClick; override;
|
||||
end;
|
||||
|
||||
{ TCocoaWSRadioButton }
|
||||
|
||||
TCocoaWSRadioButton = class(TWSRadioButton)
|
||||
@ -255,6 +263,21 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TLCLRadioButtonCallback }
|
||||
|
||||
procedure TLCLRadioButtonCallback.ButtonClick;
|
||||
var
|
||||
SubView: NSView;
|
||||
begin
|
||||
if NSButton(Owner).state = NSOnState then
|
||||
begin
|
||||
for SubView in NSButton(Owner).superView.subviews do
|
||||
if (SubView <> Owner) and (SubView.lclGetTarget is TRadioButton) then
|
||||
NSButton(SubView).setState(NSOffState);
|
||||
end;
|
||||
inherited ButtonClick;
|
||||
end;
|
||||
|
||||
{ TLCLButtonCallback }
|
||||
|
||||
procedure TLCLButtonCallback.ButtonClick;
|
||||
@ -399,7 +422,7 @@ class function TCocoaWSRadioButton.CreateHandle(const AWinControl: TWinControl;
|
||||
var
|
||||
btn: NSButton;
|
||||
begin
|
||||
btn := AllocButton(AWinControl, TLCLCheckBoxCallBack, AParams, 0, NSRadioButton);
|
||||
btn := AllocButton(AWinControl, TLCLRadioButtonCallback, AParams, 0, NSRadioButton);
|
||||
Result := TLCLIntfHandle(btn);
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user