This works, but there are some complications that raise some questions.
1. LiveCode will only allow painting into the image that is in the top layer. So to control which of my image objects gets the paint, my scripts always set the layer of the target image to "top" before painting, and then return the image to its previous layer after painting. This works.
Code: Select all
put the layer of image "Canvas1" into tSavedLayer
set the layer of image "Canvas1" to top
-- invoke the paint tools
set the layer of image "Canvas1" to tSavedLayer
Code: Select all
set the paintTarget to image "Canvas1"
-- invoke the paint tools
set the paintTarget to image "Canvas2"
-- invoke the paint tools again
set the paintTarget to empty -- return to LiveCode default behavior
2. When the image is large, I put it in a group with a vertical scrollbar. Apparently, there are some behind-the-scenes constraints on the layers of groups and their objects. In particular, an attempt to move a grouped image object to the top layer fails at runtime.
My current workaround is to have my painting scripts first ungroup the scrolling group, move the image object to the top layer, paint into it, then select that object and the other objects that were also previously in the group, and then group the selectedObject. In the one case I have tried, this seems to work. Note that it does not seem to be necessary to return the image object to its previous layer before regrouping.
However, if my group object has properties, including a script, are they always preserved across this ungroup/group action? Again, in the one case I have tried, this seems to work.
But if I do the task in two steps, and I look at the Project Browser between the steps, the group object does not appear. Is it somehow "remembered" so that the next group command brings it back, with all its properties and its script intact?
Is this always the case with an ungroup/group sequence, whether scripted or manual? For example, if I create a group containing, say, radio buttons, give that group object some properties and a script, later change my mind and ungroup, and then group a different set of objects, do I get a new group object or the old "remembered" group object?
My concern is that there might be situations where ungrouping and regrouping would affect the layering of objects, resulting in objects that were previously visible becoming hidden by the new group.
More generally, is there a simpler approach that would facilitate painting into a large image object that is inside a scrolling group?
Thanks for your help.