A game framework written with osu! in mind.
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2// See the LICENCE file in the repository root for full licence text.
3
4using System;
5using osu.Framework.Bindables;
6using osu.Framework.Input.Events;
7
8namespace osu.Framework.Graphics.Containers
9{
10 public class ClickableContainer : Container
11 {
12 private Action action;
13
14 public Action Action
15 {
16 get => action;
17 set
18 {
19 action = value;
20 Enabled.Value = action != null;
21 }
22 }
23
24 public readonly BindableBool Enabled = new BindableBool();
25
26 protected override bool OnClick(ClickEvent e)
27 {
28 if (Enabled.Value)
29 Action?.Invoke();
30 return true;
31 }
32 }
33}