Custom Canvas Control IDE

When creating a custom control based on a canvas, is there a way to show something when the user drags it on the form (design mode), or makes changes to a property like backcolor?

I’m creating some controls like a button, a checkbox etc, but on the design form, they all look alike (a rectange) and it’s hard to see what is what.

no

Well, that is a bit harsh Norman :slight_smile: It looks like the ContainerControl can show something in design mode. Could I use the ContainerControl with its paint event and emulate a Canvas? Or are there drawbacks doing this?

It was a straight answer to your question though!

I don’t think putting your canvas in a container control will help since you’re still drawing custom things. I think container controls have the same limitation and will only show xojo controls that are inside it during design.

Well, he did answer your question.

Here’s what I’ve done in the past with custom canvas based controls. Get a screenshot of the control, in action, and put it as the background. At least you can see, in the IDE, what the control looks like.

Bob beat me to it… put a “picture” of your control in the BACKDROP of the canvas… this does show in the IDE.

Was goofing guys. I know Norman did answer my question. Going to try the backdrop idea!

It’s the huge limitation of custom controls in the IDE.

How is the IDE supposed to reflect what will be going on in the Paint event of the canvas ?

The backdrop idea is a very sensible solution to show custom controls in the IDE.

Yes, but it would’ve been nice if the IDE could reflect the property settings on the custom control. eg. a ContainerControl with a label in it and its text property is shown in the Inspector. User changes the label text property -> the content of the label in the IDE on the form changes to the new content.

Now, when I put 10 custom button controls on a form, they all look the same and its harder to find back which is which (You have to look int the Inspector for find the one back you are looking for.

I’m splitting hairs, but we can keep dreaming, no? :wink:

[quote=161317:@Michel Bujardet]How is the IDE supposed to reflect what will be going on in the Paint event of the canvas ?

The backdrop idea is a very sensible solution to show custom controls in the IDE.[/quote]
Execute the paint event. It’s not unheard of. VB does it with activex controls in the IDE.

And what do we do if the Paint event refers to a recordset or calls a method?

No
Your code is not run so it would not matter

ActiveX controls are more or less sandboxed from the rest of the app
So they can be “run”
A custom control in your app might, in its paint event, run other code which calls other code which … :slight_smile:
There are some thoughts on something we might be able to do but its just thoughts at this point & its not running the paint event

Greg I don’t know. As I said, it’s not unheard of. I can’t help you with that ask MS what they do in VB. Norman seems to know.

[quote=161391:@Norman Palardy]ActiveX controls are more or less sandboxed from the rest of the app
So they can be “run”
A custom control in your app might, in its paint event, run other code which calls other code which … :slight_smile:
There are some thoughts on something we might be able to do but its just thoughts at this point & its not running the paint event[/quote]
But Norman, an activex could call all sorts too but it is still done. Is the answer here “yes of course this could be done in xojo but it’s a massive amount of work and just won’t happen”

It seems quite out of the extraordinary to want custom controls to be run like Active X in the IDE, when native controls are not… Especially when a simple backdrop image can provide a valid mockup of the custom control in seconds…

New pragma maybe?

g.ForeColor = &c000000
g.FillRect(0,0,g.Width,g.Height)
#if DESIGN_MODE then
// sample
g.ForeColor = &cFFFFFF
g.DrawString("In Design Mode!",10,10)
#else
g.DrawString( me.Text , 10, 10)
#end if

This has been brought up in the past. It would require the IDE to run some level of code that is outside of their control which opens it up to all sorts of abuse and complaints. Say you buy widget A from me and it crashes the IDE because I did something stupid. Is that my fault of Xojo’s? I guarantee that most people would blame Xojo for my mistake.

ActiveX got away with it because MS has very clear and detailed rules on how it would work and what the IDE’s could and couldn’t do at design time. Xojo might be able to do something like that but it would require COM (or similar) which it does not fully support. Not impossible - just improbable in the near term as they have plenty of things on the plate (64 bit support anyone?).

So, could they? Of course. Will they? I’m skeptical for the above said reasons. Doing a simple picture would be no big deal, but then people would want the control to work like it was in a built executable which is considerably harder and has a bigger chance to go wrong. There are just to many variables.

How does this work with plugin controls? It’s been a while since I last looked at the SDK, but isn’t there a call to have the control draw itself to the IDE?