// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Framework.Bindables; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Events; namespace osu.Framework.Graphics.UserInterface { /// /// An abstract class that implements the functionality of a checkbox. /// public abstract class Checkbox : Container, IHasCurrentValue { private readonly BindableWithCurrent current = new BindableWithCurrent(); public Bindable Current { get => current.Current; set => current.Current = value; } protected override bool OnClick(ClickEvent e) { if (!Current.Disabled) { Current.Value = !Current.Value; OnUserChange(Current.Value); } base.OnClick(e); return true; } /// /// Triggered when the value is changed based on end-user input to this control. /// protected virtual void OnUserChange(bool value) { } } }