ppy / osu-framework

A game framework written with osu! in mind.
MIT License
1.64k stars 411 forks source link

`TabItem<T>` always has false `Enabled.Value` #4754

Open LeNitrous opened 3 years ago

LeNitrous commented 3 years ago

This is because TabItem inherits from ClickableContainer which has Action and Enabled. But only Enabled.Value is set when Action has value. TabItem overrides OnClick and has its own ActivationRequested action which is invoked by the TabControl<T> thus being the reason why it still can be clicked on even if Enabled.Value is false.

A sane solution would be to do something like

Action = () => ActivationRequested?.Invoke(this);

This would also make way to allowing disabling specific tabs which I think isn't possible at the moment.

I'm unsure if there are other reasons why Action is unused. I'll take on creating a PR after hearing the thoughts of others.

peppy commented 3 years ago

Does this lead to an actual issue?

LeNitrous commented 3 years ago

Specific to my project where I need to set the enabled/disabled visual state of a tab item. I was rather confused as to why Enabled.Value was always false when TabItem was inheriting from ClickableContainer.

peppy commented 3 years ago

I think you can go ahead and make a PR with tests, sounds like a sane direction. Only potential issue is avoiding a consume overwriting the action, causing the tab control not to work (my need consideration, with a new implementation of Action).