Custom Canvas Control & Font Settings In Inspector

I could have sworn I did this before, but perhaps I’m dreaming:

I’m creating a custom control based on a canvas and I want to be able to set the font settings on the second page of the inspector just as if it was a label for instance:

Is this possible or am I just dreaming…

Thanks.

AFAIK, the canvas control has never had a font property. Only the graphics object passed to the paint event has such a property.

What you want is hidden pretty well. Select your custom control in the Navigator and select Inspector Behavior. It’s the last entry.

Oh… Never knew you could do that!
Works in 2017r2 haven’t tried in anything newer.

Inspector behavior:

Inspector:

You might have to save/ reopen etc to get the ide to update the inspector

I guess I’m missing something… I know how to find and bring up the Inspector Behavior dialog, what I can’t see in that dialog is any property in there I can select to cause the Font properties to appear:

I realise that, but I thought there was a way to create your own custom property, have it appear in the properties list and then use it in the graphics object.

There is.

create a subclass of Canvas, add a computed property for both Font and FontSize, go to Inspector Behaviour, and make them visible.

OK, there it is. Dave has pointed out that you must add that property to your custom control. It is not natively a property of canvas.

[quote=415561:@Dave S]There is.

create a subclass of Canvas, add a computed property for both Font and FontSize, go to Inspector Behaviour, and make them visible.[/quote]

Thanks Dave.

Well some progress:
Making a Font group caused it to appear on the second page and setting a property to FontUnits got me the units dropdown. The booleans are still switches rather than check boxes, which I can live with, but the font list is still missing…

Uh… have you tried adding a property for TextFont, TextSize, TextUnit, Bold, Italic and Underline? You might get the default pickers if you do that.

I found this discussion since I, too, wanted to add the Inspector Font section to my custom control. However, this thread seemed to me to be unresolved. So I did some testing and found that in order to get the font menus and selectors to be generated in the Inspector, the properties must all be present and named and listed as in the Font section in the image below. Otherwise they are just treated as individual property fields.

Probably this has already been widely known but I’m posting this in case someone else enjoys my level of confusion.

(BTW, I copied this image from Jim McKay’s posting above.)

I mentioned this 2 years ago :slight_smile:
https://forum.xojo.com/conversation/post/359171

[quote=438293:@Norman Palardy]I mentioned this 2 years ago :slight_smile:
https://forum.xojo.com/conversation/post/359171[/quote]
Sorry. I missed it in my search.

NP …
this was more “I could swear I mentioned this before why cant anyone find it?”
so I went looking as well

seems this would be a useful bit in the user guide
<https://xojo.com/issue/55790>