custom resize group handler

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

billworld
Posts: 188
Joined: Sat Oct 25, 2008 12:32 am

custom resize group handler

Post by billworld » Sat Mar 24, 2012 10:55 pm

I need a resize group handler. The code examples for this posted in the thread at http://forums.runrev.com/viewtopic.php? ... ler#p26344 aren't working for me. (The first doesn't operate as expected and the second one throws errors in the code.)

I've attached a visual example of what I'm trying to accomplish. That is, simply to be able to grab a lower-right handle for a group and drag resize the group with fields repositioned horizontally and vertically. I need to be doing this for lots of different groups, so I need to understand how to build an all-purpose and generic solution.

Any help with this is greatly appreciated.

Thanks

Bill
Attachments
resize group example.livecode.zip
(1.5 KiB) Downloaded 268 times

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: custom resize group handler

Post by Mark » Sun Mar 25, 2012 2:24 am

Hi Bill,

This should get you started. Create a graphic, group the graphic, set the margins of the new group to 1, set the selectGroupedControls of the group to false and set the script of the group to

Code: Select all

on resizeControl
     if the long id of the target is the long id of me then
          put the rect of me into myRect
          add 1 to item 1 of myRect
          add 1 to item 2 of myRect
          subtract 1 from item 3 of myRect
          subtract 1 from item 4 of myRect
          set the rect of grc 1 of me to myRect
     end if
end resizeControl
Now use the pointer tool to resize the group.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

billworld
Posts: 188
Joined: Sat Oct 25, 2008 12:32 am

Re: custom resize group handler

Post by billworld » Sun Mar 25, 2012 4:17 am

Thanks Mark but I don't follow. In case my description and the attached stack was not clear, I need a way for the user to resize a group of objects as indicated in the stack I provided. To be clear, the user would grab the resize handle within the grouped object and move it horizontally/vertically and the grouped objects would resize as pictured in the stack I provided.

I don't follow how your suggestion accomplishes this. Thanks for clarification.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: custom resize group handler

Post by Mark » Tue Apr 03, 2012 11:20 pm

Hi,

What you describe is exactly what my script does. The only difference is that this works when you resize your object with the pointer tool. If you want, you can use four tiny buttons that the user can drag with the browse tool and set the rect of your group accordingly the locations of the tiny buttons. My script should run automatically whenever you set the rect of your group. If it doesn't, just send the resizeControl message to it whenever you deem appropriate.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

billworld
Posts: 188
Joined: Sat Oct 25, 2008 12:32 am

Re: custom resize group handler

Post by billworld » Wed Apr 04, 2012 3:14 pm

Thanks Mark. I'm still new to this and need help with concepts. If you could in any way actually make the required edits to the stack I attached that would help get me going. You refer to "pointer tool" and "browse tool". By "browse tool" do you mean the user's mouse?
Mark wrote:Hi,

What you describe is exactly what my script does. The only difference is that this works when you resize your object with the pointer tool. If you want, you can use four tiny buttons that the user can drag with the browse tool and set the rect of your group accordingly the locations of the tiny buttons. My script should run automatically whenever you set the rect of your group. If it doesn't, just send the resizeControl message to it whenever you deem appropriate.

Kind regards,

Mark

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: custom resize group handler

Post by bn » Wed Apr 04, 2012 3:20 pm

Hi Bill,

here is your stack with the resizing.
ResizeGroup_0.0.4.livecode.zip
(2.48 KiB) Downloaded 342 times
it is commented in the code of the graphic handler.

since you mentioned a stack that I posted
and the second one throws errors in the code.)
I would be interested in what errors it did throw and when. I tested the stack and did not find errors. Please mention Operating System and Livecode / Runrev Version.

Kind regards

Bernd

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: custom resize group handler

Post by Mark » Wed Apr 04, 2012 3:27 pm

Hi,

My time is too valuable to take stacks from this forum and edit them, but clearly Bernd doesn't mind doing so. I guess you don't need my advise now.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

billworld
Posts: 188
Joined: Sat Oct 25, 2008 12:32 am

Re: custom resize group handler

Post by billworld » Thu Apr 05, 2012 9:32 am

Thanks much Bernd. That works wonderfully. Exactly as expected. Much appreciated.

The errors I had experienced referenced in earlier posts was when I was on LiveCode 4.6.x on Mac OS 10.6.8. I've recently updated to LC 5.5. I haven't retested the other code in this version.

Thanks again for the handholding on this one. I'll look forward to digging through the code to gain understanding on this.

Best,

Bill
bn wrote:Hi Bill,

here is your stack with the resizing.
ResizeGroup_0.0.4.livecode.zip
it is commented in the code of the graphic handler.

since you mentioned a stack that I posted
and the second one throws errors in the code.)
I would be interested in what errors it did throw and when. I tested the stack and did not find errors. Please mention Operating System and Livecode / Runrev Version.

Kind regards

Bernd

billworld
Posts: 188
Joined: Sat Oct 25, 2008 12:32 am

Re: custom resize group handler

Post by billworld » Thu Apr 05, 2012 9:47 am

Bernd:

I just tested your "Resize with handle" stack from the other thread and got the attached error on LC 5.5 Mac 10.6.8 when in browse mode and selecting the bottom gray circle and attempting to drag it. That's what I had done before. Maybe that's not what a user is supposed to do but that's the first thing I thought to try.

Thanks again for the great working code you posted in the ResizeGroup stack.

Regards,

Bill
Attachments
resize with handle error.png

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: custom resize group handler

Post by bn » Thu Apr 05, 2012 11:26 am

Hi Bill,

thanks for pointing the error out.

It turns out that I used the long id for the current object, which includes the whole path to the stack. This throws an error the if you click on the handle of the object the first time you open the stack and the stack path has changed.

As soon as you Alt-click on an object it aquires the correct path to the control. Since I tested on the same stack with a constant path I did not notice this.

Kind regards

Bernd

lolokiki
Posts: 11
Joined: Thu Apr 12, 2012 8:35 am

Re: custom resize group handler

Post by lolokiki » Thu Apr 12, 2012 8:44 am

Hello,
I do not speak English very well so sorry for saying bad words.
Thank you for your excellent stack but I have a problem with the quicktime players.
I can not seem to me to "take off" the controller reziser!?!
Do you have a solution? thank you in advance

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: custom resize group handler

Post by bn » Thu Apr 12, 2012 11:21 am

Hi lolokiki,

welcome to the forum.

what do you mean by "quicktime players"? Do you want to hide the controls of a player object?

Please try to explain a little more what you want to do and what the problem is.

Kind regards

Bernd

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: custom resize group handler

Post by shaosean » Thu Apr 12, 2012 11:33 am

I think the custom resize handles are not being removed from the player control when not needed..

lolokiki
Posts: 11
Joined: Thu Apr 12, 2012 8:35 am

Re: custom resize group handler

Post by lolokiki » Thu Apr 12, 2012 11:39 am

I have an application where the user has images, text fields, sounds and videos (by quicktime players). I was looking for a way to change the size of all these and I found your app on the forum. It responds almost entirely to my desires but if the user tries to resize the quicktime player the user is stuck on resizing script.
I hope I was a little clearer? :-s

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: custom resize group handler

Post by bn » Thu Apr 12, 2012 11:48 am

Hi lolokiki,

do you mean the stack I posted in this thread called "ResizeGoup_0.0.4"? or the stack mentioned also in this thread which is posted in thread
http://forums.runrev.com/viewtopic.php? ... ler#p54555
called "Resize with handle_0.0.2"?

Kind regards

Bernd

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”