Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Respond to Activated event
Browse files Browse the repository at this point in the history
  • Loading branch information
JunielKatarn committed Apr 10, 2021
1 parent caab66b commit 120620d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Xamarin.Forms.Platform.MacOS/Renderers/RadioButtonRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ protected override void Dispose(bool disposing)
{
ObserveStateChange(false);

var formsButton = Control as FormsNSButton;
if (formsButton != null)
{
formsButton.Activated -= HandleActivated;
}

base.Dispose(disposing);
}

Expand All @@ -44,6 +50,8 @@ protected override void OnElementChanged(ElementChangedEventArgs<RadioButton> e)
btn.SetButtonType(NSButtonType.Radio);
SetNativeControl(btn);
ObserveStateChange(true);

btn.Activated += HandleActivated;
}

UpdateContent();
Expand Down Expand Up @@ -156,5 +164,15 @@ void OnStateChanged()

Element.IsChecked = Control.State == NSCellStateValue.On;
}

void HandleActivated(object sender, EventArgs args)
{
if (Element == null || sender == null)
{
return;
}

Element.IsChecked = (sender as FormsNSButton).State == NSCellStateValue.On;
}
}
}

0 comments on commit 120620d

Please sign in to comment.