extend or subclass?

I’m using webGraphics to draw object on my webCanvas.
I want to define a method that draws a line with an arrow head.
Would you extend or subclass WebGraphics?

Subclass. Use extends only when you can’t subclass.

I disagree with this, actually. I think subclassing should only be done when an efficient implementation of the function is impossible otherwise or when it makes the most sense from the perspective of the type hierarchy.

So when I get a paint message that has g as webgraphics as a parameter
then:

dim myweb as myWebGraphics
myweb = myWebGraphics(g)

[quote=184524:@Brian O’Brien]So when I get a paint message that has g as webgraphics as a parameter
then:

dim myweb as myWebGraphics myweb = myWebGraphics(g) [/quote]

This won’t work. The object you’re getting is an instance of WebGraphics and not your subclass.

I would go with an extension method like you mentioned or a normal method that takes a WebGraphics instance to draw to.

is it possible to do the same with a line control ( in the desktop version) ? add an arrow at any end.
subclass or extension ?
I did not succeed . thanks.

No. The line class doesn’t expose its drawing events, so you can’t affect its appearance.

[quote=184554:@jean-yves pochez]is it possible to do the same with a line control ( in the desktop version) ? add an arrow at any end.
subclass or extension ?
I did not succeed . thanks.[/quote]

Neither. Line is shamefully bugged and wonky. You never know when it will decide to do something entirely different than what you set.

Better create a custom line based on a canvas, where it is easy to add arrows.

with the custom canvas you cannot put a nice small icon in the ide … :frowning:

Third party plugins can do that. With a custom canvas I only get grey boxes. What should I do to get my custom canvas look like xojxo build in controls? What is the trick?

There isn’t one
It isn’t possible at this time

For example: I thougth of the Einhugur DateControl plugin. When it is placed at design time on a window it looks like a Xojo control and not like a grey box. So I thought there is a way to put a custom canvas into a plugin, do some magic and then it is shown like a real control in the IDE at design time.

That is not possible at this time unless its a plugin - like Einhugur DateControl

Thanks for the answer Norman.

Do you know if there is some documentation or hint, how we can put a cusotm canvas control into an own plugin to make it look like a real control at design time?