User resizable and movable objects

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
robertn
Posts: 5
Joined: Tue Mar 08, 2011 3:22 am

User resizable and movable objects

Post by robertn » Tue Mar 08, 2011 4:09 am

I'm a total newbie to LiveCode, but am loving it so far! I'm building a visual editor, and wondering if there is some way to make objects selectable, draggable, and resizable. Kind of like in most visual layout/editor programs. You move objects around, select one and resize it, etc.

Thanks in advance!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: User resizable and movable objects

Post by dunbarx » Tue Mar 08, 2011 5:38 am

Hmmm.

You have never dragged an object? How do you normally create new buttons or fields? When you are in edit (as opposed to browse) mode, don't you drag objects around, resize them by dragging their handles, etc.?

If not, you will soon be loving LC much, much more. The methods are fun and easy.

I am missing something. Write back....

Craig Newman

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: User resizable and movable objects

Post by FourthWorld » Tue Mar 08, 2011 3:19 pm

Search for "tool" in the Dictionary, noting the "choose" command to choose the current tool mode and the "pointer tool" as the mode you're looking for.

Good news: the LC IDE is made entirely in LC, so anything you see it do can be done in your own projects.

Bad news: the tool is a global properties, not specific to a stack, and affects all toplevel windows. This makes it easy to work with if your drawing area is in a separate stack, but can be problematic if you want to use a more modern design in which your toolbox and your drawing area are both in the same stack.

The cantSelect property can be useful to minimize some of the side-effects of the tool being a global mode, set for all objects outside of the drawing area. But there's another trick that can make things even easier: You can set the selected property of controls regardless of which tool is currently in use. This allows you to have a drawing area as a group with a mouseEnter handler to keep things outside of it clickable with the normal browse tool, while still retaining the selection handles.

This may sound like a lot of work at first, and indeed it would be nice to see my proposal in the RQCC for having tool modes for groups implemented, but it's doable and much easier than attempting to emulate pointer tool behaviors with the browse tool.

Another tip: you can make some very nice custom objects for your drawing app using groups. Groups have their own selectGroupedControls property, and if you set that to false then your grouped object behaves like a single control. You can trap the resizeControl message in the group to adjust its contents as the user resizes it, and you can use behaviors to keep all of your code for the instances of that custom object type in one place for easy maintenance.

Since this is all new to you, I would suggest first making the app with the tools in a separate palette to get you started. If you decide to move those into the main window later you can go back and add in the code needed to maintain the different tool modes depending on the mouse location easily enough, but starting out with the tools separate will probably help you learn the basics a little more quickly and with less frustration, building the confidence needed to later expand it into the app of your dreams.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

robertn
Posts: 5
Joined: Tue Mar 08, 2011 3:22 am

Re: User resizable and movable objects

Post by robertn » Tue Mar 08, 2011 9:12 pm

What I'm trying to accomplish is to make an editor for another thing, where users (not me in livecode) can add objects, which are just rectanlges for now. How do I make an object resizable and movable by the user in a standalone application. Sorry for any confusion, and yes, @dunbarx, I have dragged and resized objects. :-)

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: User resizable and movable objects

Post by FourthWorld » Tue Mar 08, 2011 9:24 pm

I wasn't kidding: you're looking for the pointer tool. To create objects see the graphic tool or the clone or copy commands.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

robertn
Posts: 5
Joined: Tue Mar 08, 2011 3:22 am

Re: User resizable and movable objects

Post by robertn » Tue Mar 08, 2011 9:29 pm

Ok, now that I have LiveCode open, I believe you. Can't believe I didn't know that... Thanks so much for your help!

robertn
Posts: 5
Joined: Tue Mar 08, 2011 3:22 am

Re: User resizable and movable objects

Post by robertn » Tue Mar 08, 2011 9:35 pm

Ok, another newbie question. I can't find the cantSelect property in the inspector. How do I set it in code?

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: User resizable and movable objects

Post by Klaus » Tue Mar 08, 2011 9:45 pm

Hi Robert,

...
set the cantselect of btn "xyz" to false ## or true
...
:D


Best

Klaus

robertn
Posts: 5
Joined: Tue Mar 08, 2011 3:22 am

Re: User resizable and movable objects

Post by robertn » Tue Mar 08, 2011 9:50 pm

Wow, I had it right i was just setting it to false, thinking I didn't want it to be selectable. Thanks, got it working!

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

Re: User resizable and movable objects

Post by shaosean » Wed Mar 09, 2011 12:55 am

You can actually resize an object without switching to the pointer tool, just requires a little bit of code to do so..

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: User resizable and movable objects

Post by dunbarx » Wed Mar 09, 2011 4:08 am

I wrote a gadget to resize with the browse tool. Let me know if you want it.

Craig Newman

keithglong
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 348
Joined: Sun Jul 03, 2011 2:04 am

Re: User resizable and movable objects

Post by keithglong » Thu Feb 19, 2015 10:22 pm

Hi Craig,

I realize that this thread is quite old, but is your "gadget" still available?

Regarding using the pointer tool to resize controls, I am testing using a standalone. I am able to select and resize buttons using the pointer tool, but I have a locked text field that I am able to select but can't resize. Any ideas as to what is wrong?

Thanks!

Best regards,

- Boo

Post Reply