Inheriting from Label

Hi all,
I’m trying to inherit from Label, as I want to add some custom features.
However I’m not sure how to get the TextEditor to show when editing.
std::unique_ptr<TextEditor> editor; is a private variable so it can’t be accessed by my new class NumberLabel.

Any pointers (no pun intended :smiley:) in the right direction?

The JUCE API prefers aggregation for customising features of Components instead of inheritance.
For that purpose, there is the LookAndFeel class.
You inherit from the version you are using (LookAndFeel_V4 as current default), and override the behaviour you want to change.

Here is a tutorial.

Hope that helps

How can you add features in a look and feel? I was under the impression it’s view code and not behavioral logic.

So how do you not subclass in JUCE to add behavior and API? (seems like what he is asking)

1 Like

Ok, I thought it works like the creating the Label in the Slider, which is accessible by a LookAndFeel callback.

However, this is created differently, here you have to override the Label::createEditorComponent(), so you can access it before you return it.

A little bit inconsistent, I agree.

1 Like

Right ok this is about like the current UI framework I use. So that is a factory to setup the instance and great to see btw.