Determine "this canvas"

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Determine "this canvas"

Post by [-hh] » Tue Oct 10, 2017 5:55 pm

If I have several objects of type Canvas, how can I determine which one to use for drawing the widget?
shiftLock happens

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: Determine "this canvas"

Post by LCMark » Wed Oct 11, 2017 8:39 am

@hh: The only canvas which can be used to draw to the widget, is 'this canvas' as it is at the start of the OnPaint handler. The canvas provided there only exists for as long as the OnPaint handler runs - any other Canvas's are 'offscreen' canvas objects which can be used to produce images.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Determine "this canvas"

Post by [-hh] » Wed Oct 11, 2017 10:59 am

Thanks.

I'm trying to write a basic Canvas cheat sheet and was looking for the reason why we have to write in OnPaint such often "this canvas" although there is only one.

Now I see the way to do complicated (and time consuming) but "static" parts of an OnPaint handler only once and then insert these, whenever needed, as pixel data of <otherCanvas>.

This is probably faster than to organize the layering of several widgets. And easier, especially if some of theses layers are native.
shiftLock happens

Post Reply

Return to “LiveCode Builder”