User resizable and movable objects
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
User resizable and movable objects
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!
Thanks in advance!
Re: User resizable and movable objects
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
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
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: User resizable and movable objects
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.
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: User resizable and movable objects
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. 

-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: User resizable and movable objects
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: User resizable and movable objects
Ok, now that I have LiveCode open, I believe you. Can't believe I didn't know that... Thanks so much for your help!
Re: User resizable and movable objects
Ok, another newbie question. I can't find the cantSelect property in the inspector. How do I set it in code?
Re: User resizable and movable objects
Hi Robert,
...
set the cantselect of btn "xyz" to false ## or true
...
Best
Klaus
...
set the cantselect of btn "xyz" to false ## or true
...

Best
Klaus
Re: User resizable and movable objects
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!
Re: User resizable and movable objects
You can actually resize an object without switching to the pointer tool, just requires a little bit of code to do so..
Re: User resizable and movable objects
I wrote a gadget to resize with the browse tool. Let me know if you want it.
Craig Newman
Craig Newman
-
- VIP Livecode Opensource Backer
- Posts: 348
- Joined: Sun Jul 03, 2011 2:04 am
Re: User resizable and movable objects
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
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