Page 1 of 1

Drag & drop a group inside another group (post #1)

Posted: Tue Aug 18, 2015 8:18 pm
by JeanGuilbault
Bonjour

I'm trying to grab a group and have it change position with another group inside a parent group
( who is displaying many of them as a list).

The code I have at the moment (LiveCode version 7.0.6 on Mac, Commercial License) works on Windows, Mac, IOS and Android , all with the same visual, wich is one of our app prerequisit.


I encoutered a couple of problems I had to solve and some I'm not presently able to find a solution to.

Does any of you have sucessfully scripted a drag and drop of a group part of a group list inside a parent group?

One of my major problem is to get the grabeb group to display over all the groups in the list. If the grabbed group is the third one of let's say a list of 20. The grabbed group will display over group 1 and 2, and will display under all the other group, because it's layer number is less then their layers.


In my present project I am trying to do the following:

Using script,
Create a group call grpPanel01 (done)

Inside this group create a template (grpGridTemplate01)of a group that will be replicated x time
based on an array holding some info.
This template presently hold a rectangle with a field for the ID of the group (done)

My script then loops to, let's say 18 times, and create 18 groups using the template above , called grpGrid01 to grpGrid18.
The scrip position each group created starting from the top of the group grpPanel01,
and add 4 pixel to each iteration of the group. (done)

I was getting a result where some group created where being displayed or spilling over may panel dimension.
I resolved the problem by locking the screen at the beginning of the scrip and adding a loop after the groups had been created.
This loop go and rename all the grpGridXX with a number sucha as grpGrid01 , etc..
then a unlock the scree. The result is that the groups display as a list inside the dimension of the panel and a scrollbar appears if the numbers of the groups to be display is more then can fit the size of the parent panel. (done)

After this step I created an object (graphc) gridOver that will be invisible but get a layer number that is biger then the
last grpGrid group created. This layer number will be use for the next step (done)

In the previous loop where I created de grids this scrip is added to every grdGrid group the following code:
// Attache code en script pour GrabMe
put "on mouseDown" & return \
& "grab Me" & return\
& "set the relayerGroupedControls to true" & return\
& "set the layer of me to the layer of graphic " & quote & "gridOver" & quote & return\
& "set the relayerGroupedControls to false" & return\
& "end mouseDown" into tCode
set the script of it to tCode

This enable me to grab a group and move it over any of the other groups in the list, the reason being that the layer of the grabbed group it realy being switch with the invisble group layer who as been created at the end for just this job. (done)

If I drop this group and grab a new one I get inconsistant results in the redrawing of the list (this is what I am presently working on...)

So, if any of you have faced a similar problem and have found some amazing ways to deal with it, Please give me your feedback and comments..

(I'm cleaning up my test code and then I will post it)

Merci
Jean Guilbault

Re: Drag & drop a group inside another group (post #1)

Posted: Wed Aug 19, 2015 1:21 pm
by Klaus
Bonjour Jean,

can't you do this with a dragimage and dragdata? Know what I mean?
Just like dragging objects from the TOOLS palette in the IDE?
And act on "dragdrop" accordingly?

At leat I would try this, but I was never a friend of using "relayergroupedcontrols" in a script :D


Best

Klaus

Re: Drag & drop a group inside another group (post #1)

Posted: Wed Aug 19, 2015 2:42 pm
by JeanGuilbault
Bonjour Klaus,

I am trying to keep my code working on all platform: Windows, Mac, IOS and Android.
So I try as much as I can that my code works on the different hardware without (when possible) using any call to specific API.

The Drag & Drop commands works on Windows and Mac, and not on IOS and Android.

Up to now, I manage to have code that if a group goes over another group , the group under the object being drag will hi-light or to something else.
And this works on all plateforms.

The Grab command also works on all platforms.

So today I will keep working on ways to have my selected and grabbed group appear in front when it is being drag.

Merci for your comments
Jean

Re: Drag & drop a group inside another group (post #1)

Posted: Wed Aug 19, 2015 2:45 pm
by Klaus
Bonjour Jean,

ah, yes, mobile...

Sorry, always forget this, maybe because I don't even own a cell phone at all :D


Best

Klaus