Place a rectangle on a card that has size adjustable
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Place a rectangle on a card that has size adjustable
What would be the best way to have an app place a rectangle on a card and allow the user to adjust the size and position?
Tom
Tom
-
- VIP Livecode Opensource Backer
- Posts: 9733
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Place a rectangle on a card that has size adjustable
Hi.
by "app" you mean a standalone, right? It will work the same way the stack in the IDE does.
Since you will not have the convenience of resize handles that the pointer tool provides, you need to fool around.
I made a pretty complete set of graphics, of several different shapes, so that the user could expand or contract any portion of them that he dragged. I can send you the handlers that do that, but not until Tuesday.
Abut a rectangle is much simpler. Use a mouseMove handler to detect which corner is closest, and set the "loc" of that corner, say, the topLeft, to the mouseLoc. Make sure the mouse is down. Also make sure the mouseLoc is close to a corner, before allowing this process to prrceed, or play with requiring the optionKey to be down as well. Anything to make sure the resizing only occurs when you want it to.
Craig
by "app" you mean a standalone, right? It will work the same way the stack in the IDE does.
Since you will not have the convenience of resize handles that the pointer tool provides, you need to fool around.
I made a pretty complete set of graphics, of several different shapes, so that the user could expand or contract any portion of them that he dragged. I can send you the handlers that do that, but not until Tuesday.
Abut a rectangle is much simpler. Use a mouseMove handler to detect which corner is closest, and set the "loc" of that corner, say, the topLeft, to the mouseLoc. Make sure the mouse is down. Also make sure the mouseLoc is close to a corner, before allowing this process to prrceed, or play with requiring the optionKey to be down as well. Anything to make sure the resizing only occurs when you want it to.
Craig
Re: Place a rectangle on a card that has size adjustable
Thanks Craig,
I would appreciate the code you wrote.
What I am trying to do is allow a user to easily define where he can place pictures and text on a page, so I am trying to make it as intuitive as possible for the end user.
Tom
I would appreciate the code you wrote.
What I am trying to do is allow a user to easily define where he can place pictures and text on a page, so I am trying to make it as intuitive as possible for the end user.
Tom
-
- VIP Livecode Opensource Backer
- Posts: 9852
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Place a rectangle on a card that has size adjustable
There are many ways, but the easiest might be to give them the pointer tool:
You'll also want to choose the browse tool when they're done, or provide a means for them to do so.
If the controls for changing tool mode aren't in a pallette window, see the cantSelect property to set those so they always use the browse tool regardless which tool may be in use globally.
Code: Select all
choose pointer tool
If the controls for changing tool mode aren't in a pallette window, see the cantSelect property to set those so they always use the browse tool regardless which tool may be in use globally.
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
-
- VIP Livecode Opensource Backer
- Posts: 4016
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Place a rectangle on a card that has size adjustable
Hi Tom,
here is a small stack that illustrates one way of doing what you want.
The script is in the card script.
Kind regards
Bernd
here is a small stack that illustrates one way of doing what you want.
The script is in the card script.
Kind regards
Bernd
- Attachments
-
- markRectAdaptable.livecode.zip
- (1.24 KiB) Downloaded 99 times
Re: Place a rectangle on a card that has size adjustable
Thanks Richard, I'll try this.
Tom
Tom
-
- VIP Livecode Opensource Backer
- Posts: 9852
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Place a rectangle on a card that has size adjustable
Be sure to check out what Bernd posted as well. I haven't seen it yet, but he's a powerhouse of useful examples, always worth exploring what he takes the time to craft.
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
-
- Posts: 101
- Joined: Mon Jan 03, 2022 7:10 pm
Re: Place a rectangle on a card that has size adjustable
I second the use of the command "choose pointer tool" this will also give you the resize handles when the object is selected.
-
- VIP Livecode Opensource Backer
- Posts: 9733
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Place a rectangle on a card that has size adjustable
In my resizing gadgetry, where some graphics have shapes like a staircase and one can resize at any vertex, I change the cursor when one get close to said vertex, and then allow resizing when the mouse is down. I like this better than changing tools back and forth.
When resizing such a graphic, it is not the vertex point that is adjusted, which would distort the "staircase" shape, but rather the entire portion of the graphic "below" the vertex is stretched , keeping the overall aspect and shape intact. One would create, say, a very wide (or tall) single step in an otherwise unmodified staircase.
Lots of ways to do this, and whatever floats your boat is fine.
Craig
When resizing such a graphic, it is not the vertex point that is adjusted, which would distort the "staircase" shape, but rather the entire portion of the graphic "below" the vertex is stretched , keeping the overall aspect and shape intact. One would create, say, a very wide (or tall) single step in an otherwise unmodified staircase.
Lots of ways to do this, and whatever floats your boat is fine.
Craig
Re: Place a rectangle on a card that has size adjustable
Hi Just so everyone else knows. I messaged Berndt.
For my application his solution works exactly as I had hoped for. Other's may want to check it out.
Tom
For my application his solution works exactly as I had hoped for. Other's may want to check it out.
Tom