How to assign a default TextFont to a custom Label control?

Hello

I would like to create a custom Label for all my titles, with a specific TextFont.

How can I set a new default TextFont on my custom Label class? I don’t know how to access the control’s properties, maybe am I too tired ^^

Any advice? Thank you!

http://documentation.xojo.com/index.php/Label.TextFont

I already read this and it does not answer my question.

I would like to change the default TextFont of my custom Label control in order to see my own properties in the IDE when I use this control.

Weird… I thought setting the Inspector Behaviour would cause it to set the font, but apparently you need to do it in your subclass Open event… This worked for me…

[code]Sub Open() Handles Open
me.TextFont = “Arial”

RaiseEvent Open
End Sub
[/code]

It’s in Inspector Behavior…

Also, Hi shao sean! Welcome back!

Thanks for your answers!

I tried, as you can see on my screenshots, but when I drag’n drop my custom control in a window, the TextFont is still «System» and FontSize still 0…

In a window :

Hi Tim (thanks for the warm greetings :slight_smile: )

I tried changing it in there, but it didn’t make a difference, either in the IDE or in the debug build…

Oh I think I might have an uninformed guess as to why that might be.
Calling in @Norman Palardy though because I can confirm the behavior described.

@shao sean : I also tried your solution, but it does not work for me…

That should change the font only when the app runs, you won’t see it in the IDE.

Create an EventDefinition called Open…

Yes it’s exactly what I supposed, but I want to work in the IDE with the new properties (TextFont and FontSize).

I’m wondering if it’s possible or not… It should be I imagine…

After all, I don’t understand why it does not work by changing the default value in the Inspector Behavior…

Give the staff time to wake up. I think Norman should look at this thread before we jump to conclusions.

AFAIK, properties set in the class do not propagate to the instance. Indeed you have to set the font in the Open event.

If you set properties in Inspector Behavior... they become the default values when the control is added to the design view in the IDE. You can also control (for the most part) which properties are visible to the developer.

Not in this case :stuck_out_tongue:
What is your preference setting for Preferences > Layout > default control font and size set to ?
That will override everything else
This has been true for many years but maybe there should be a way to turn this behaviour off

In Preferences > Layout, the default font is System and FontSize 0, but I don’t know how to override this.

If XOJO allows us to change the value in Inspector Behavior, I don’t understand why it does not take these changes…

It is not terribly difficult to add a menu definition for Open, add a bit of code in the Open event of the custom class to change the font and font size, and raise the event at the end of the custom class Open.

Reread my post

It does take them - then overrides them with the settings in Default Control font & Size
Thats why

Its also why I said [quote=298733:@Norman Palardy] maybe there should be a way to turn this behaviour off[/quote]