Resizing a group

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
mtecedor
Posts: 68
Joined: Fri Sep 04, 2009 6:40 pm

Resizing a group

Post by mtecedor » Tue Nov 03, 2009 9:34 pm

Hi All,

I have a group composed of a graphic (an oval or a rectangle) and a field.

I want the end user to be able to resize the whole group maintaining the aspect ratio.

I have tried puting this code into the group:

on mouseDoubleDown
choose pointer tool
select me
end mouseDoubleDown

When in running mode, the handlers of the group appear, but they do not resize the objects conteined in it.

I have also tried

on mouseDoubleDown
choose pointer tool
select graphic ¨"oval" and field "topic"
end mouseDoubleDown

In this case the all handlers appear, which of course looks really messy.

I think I might be missing something, maybe just setting a property in the group property inspector.

Any suggestions?

Thanks,

Marta

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Tue Nov 03, 2009 10:57 pm

Marta,
how are the graphic and the field placed on the group, are they centered or do they overlap. Do you want both controls to change size or just one. All this matters when you want to change the size of the controls. What is the effect you want to achieve by changing the size of the group?
regards
Bernd

mtecedor
Posts: 68
Joined: Fri Sep 04, 2009 6:40 pm

Post by mtecedor » Tue Nov 03, 2009 11:50 pm

The scenario:
end users are constructing a mental map (something similar to what you can do with Inspiration).

So, in the group, the field "topic" is inside the graphic "oval". In some ocasions, users may want to write long sentences, so they need to be able to resize both the field and the graphic at the same time. I though placing them in a group would make it.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Wed Nov 04, 2009 3:38 pm

Marta,
I posted a stack on the new (>=3.5) RevOnline ResizeGroup. If you search for it you should find it.
You can resize the group by clicking in the lower right hand red square. If you click into the red of the oval graphic you can move the stack around.
The script is generic enough so that you can clone groups without interference (at least I hope)
Tell me what you think.
regards
Bernd
It really helps when you describe a scenario and give a little detail on what you are after. :wink:

mtecedor
Posts: 68
Joined: Fri Sep 04, 2009 6:40 pm

Post by mtecedor » Wed Nov 04, 2009 5:56 pm

Thanks Bernd, that works.

Now I am working on understanding the whole thing :?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Wed Nov 04, 2009 10:25 pm

Marta,
I discovered 2 bugs in the code I posted on RevOnline, and I corrected them. One affects the cloning of the groups. (should have tested before posting...) Now, from all I can see it works. And from what I gather from your earlier posts, you probably will want to clone the group.
Now I am working on understanding the whole thing
that is the whole fun, especially if one trys to understand one's own code... :)
If you have difficulties understanding I will be glad to help.

regards

Bernd

mtecedor
Posts: 68
Joined: Fri Sep 04, 2009 6:40 pm

Post by mtecedor » Thu Nov 12, 2009 3:37 am

More about resizing groups :oops:

The stack Bernd put on RevOnline was great. I made some modifications to fit the needs of my project.

I was able to clone groups containing different types of graphics. However, I have a couple of questions.

I realized my end users will probably want to erase some of those groups if they clone more than they need, so I added a small cross to my group. If the user double click on it the idea is that the group disappear. This is the code I have on the cross,

on mouseDoubleDown
delete the owner of me
end mouseDoubleDown

I dont know why it is not working.

This is the error message I get:
image "Delete2.png": execution error at line n/a (Object: stack locked, or object's script is executing)

The other problem I have is that i need to adjust the location of the cross if my group contains an oval, this is more complicated than if it is a rectangle or a square.

This is the code in the handler:

-- now adjust the locaction of this resize control
set the right of me to the right of grc 1 of of the owner of me
set the bottom of me to the bottom of grc 1 of of the owner of me
unlock screen

So, I though I could just add

set the left of image "Delete2" to the left of grc 1 of of the owner of me
set the bottom of image "Delete2" to the bottom of grc 1 of of the owner of me

And this is the error message I get;

image "Ohandler.png": execution error at line 59 (Chunk: no such object) near "Delete2", char 17

Any suggestions?

Thanks

Marta

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Post by sturgis » Thu Nov 12, 2009 3:54 am

edit: The other error, if you pasted your code in, i'd guess the problem is the 2nd "of" in each line, a bit tired at the moment, so if theres another issue, I can't see it.

edit2: Ok, so delete the target gets ride of ALL objects because target returns the card id. DOH. Should know better than to answer while tired. :)

Still explains why an object can't delete itself though, so its a step.

Code: Select all

set the left of image "Delete2" to the left of grc 1 [b]of of[/b] the owner of me
set the bottom of image "Delete2" to the bottom of grc 1 [b]of of[/b] the owner of me 
In this case, it means exactly what it says. You can't delete an object that is currently executing code, and since the code to delete the object is in the object its deleting, its a no win situation.

Instead try this. Its a MUCH simplified form that does zero checking of whether its really what you want to delete, but works as a proof.

Put your mouseDoubleDown script in the stack or card script.

Just as an experiment change the delete line to

Code: Select all

delete the target
This way you should be able to rampage through pretty much any objects in your stack and send em to the void.
This is the error message I get:
image "Delete2.png": execution error at line n/a (Object: stack locked, or object's script is executing)

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Post by sturgis » Thu Nov 12, 2009 4:21 am

Ok, No clue why, but if you use it works.

Code: Select all

on mouseDoubleUp 
delete the target
end mouseDoubleUp
in a stack or card script it works, mouseDoubleDown for some reason I don't understand always returns the card id as the target. /shrug

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4171
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Thu Nov 12, 2009 11:17 am

Marta,
I uploaded a version that can delete itself. Just dont let the user delete the last group, then your template group will be gone...
the trick is to send a message to the stack script in 2 milliseconds and then this script deletes the group.
I put the delete image in the upper left corner of the graphic.
regards
Bernd

mtecedor
Posts: 68
Joined: Fri Sep 04, 2009 6:40 pm

Post by mtecedor » Thu Nov 12, 2009 5:10 pm

Yes!, that works. No idea that I could put the code in the stack.

I like revolution and this forum more and more everyday :D

Post Reply