Place a rectangle on a card that has size adjustable

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trags3
Posts: 418
Joined: Wed Apr 09, 2014 1:58 am
Location: Las Vegas, NV

Place a rectangle on a card that has size adjustable

Post by trags3 » Sat Apr 29, 2023 9:52 pm

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

dunbarx
VIP Livecode Opensource Backer
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

Post by dunbarx » Sat Apr 29, 2023 11:06 pm

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

trags3
Posts: 418
Joined: Wed Apr 09, 2014 1:58 am
Location: Las Vegas, NV

Re: Place a rectangle on a card that has size adjustable

Post by trags3 » Sat Apr 29, 2023 11:19 pm

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

FourthWorld
VIP Livecode Opensource Backer
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

Post by FourthWorld » Sun Apr 30, 2023 12:26 am

There are many ways, but the easiest might be to give them the pointer tool:

Code: Select all

choose 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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bn
VIP Livecode Opensource Backer
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

Post by bn » Sun Apr 30, 2023 12:34 am

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
Attachments
markRectAdaptable.livecode.zip
(1.24 KiB) Downloaded 99 times

trags3
Posts: 418
Joined: Wed Apr 09, 2014 1:58 am
Location: Las Vegas, NV

Re: Place a rectangle on a card that has size adjustable

Post by trags3 » Sun Apr 30, 2023 1:34 am

Thanks Richard, I'll try this.
Tom

FourthWorld
VIP Livecode Opensource Backer
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

Post by FourthWorld » Sun Apr 30, 2023 3:07 am

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

Emily-Elizabeth
Posts: 101
Joined: Mon Jan 03, 2022 7:10 pm

Re: Place a rectangle on a card that has size adjustable

Post by Emily-Elizabeth » Sun Apr 30, 2023 4:08 am

I second the use of the command "choose pointer tool" this will also give you the resize handles when the object is selected.

dunbarx
VIP Livecode Opensource Backer
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

Post by dunbarx » Sun Apr 30, 2023 3:22 pm

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

trags3
Posts: 418
Joined: Wed Apr 09, 2014 1:58 am
Location: Las Vegas, NV

Re: Place a rectangle on a card that has size adjustable

Post by trags3 » Tue May 02, 2023 8:47 pm

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

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”