Resize object during runtime

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

raugert
Posts: 112
Joined: Thu May 26, 2016 9:30 pm
Location: Winnipeg, Canada

Resize object during runtime

Post by raugert » Sun Mar 04, 2018 4:55 pm

I am building an app where one can add buttons and adjust the properties (position, color, etc.). These buttons will then be used to execute commands for a video switcher. So far this works well but I can't seem to resize the button in when it is selected in runtime. If I grab the corner handles it will only move the object. I selected "resize when setting rect property" in the property inspector but it doesn't seem to help. I'm sure this an easy fix and I'm just missing something..
Livecode Indy 9.6.11 (Stable)
MacOS Sonoma 14.2
Xcode 15.0.1 SDK 17.0

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Resize object during runtime

Post by richmond62 » Sun Mar 04, 2018 7:54 pm

This sounds like you are going to be letting end-users do some sort of
simplified programming with a standalone, and that is not permitted.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9838
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Resize object during runtime

Post by FourthWorld » Sun Mar 04, 2018 7:58 pm

The pointer tool as available for use as any other tool mode. The question is why it doesn't work in the standalone.

Is this a LiveCode-native button, or one of the newer widgets?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Resize object during runtime

Post by bogs » Sun Mar 04, 2018 8:17 pm

richmond62 wrote:
Sun Mar 04, 2018 7:54 pm
This sounds like you are going to be letting end-users do some sort of
simplified programming with a standalone, and that is not permitted.
I don't know that
raugert wrote:
Sun Mar 04, 2018 4:55 pm
These buttons will then be used to execute commands for a video switcher.
would equal programming or creating an IDE, necessarily.
Image

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Resize object during runtime

Post by richmond62 » Sun Mar 04, 2018 8:43 pm

Being able to add objects might constitute something like programming: difficult to say.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Resize object during runtime

Post by richmond62 » Sun Mar 04, 2018 9:01 pm

If I grab the corner handles
I'm obviously missing something as I can see no "corner handles" on an object in a standalone.

raugert
Posts: 112
Joined: Thu May 26, 2016 9:30 pm
Location: Winnipeg, Canada

Re: Resize object during runtime

Post by raugert » Sun Mar 04, 2018 10:18 pm

@Forthworld

I can move selected objects when in (Edit Mode) as per check box. But I can't resize them from the "handles" (Yes they are there in standalone and/or "Run" mode in Livecode) . I can however resize them from the input fields. I just wanted to make it easier for the user to resize objects without having to put the value in a field...

The app basically lets users create a custom button layout and will save the info in a datagrid which will be hidden of course. It can then be saved as .csv and recalled later to reposition the buttons and their parameters.

I'm still have a long way to go on this one but here is what I have so far. Just trying to get the resizing happening..

https://www.dropbox.com/sh/0rqso8efvq4q ... FZGHa?dl=0

thanks,
Livecode Indy 9.6.11 (Stable)
MacOS Sonoma 14.2
Xcode 15.0.1 SDK 17.0

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Resize object during runtime

Post by [-hh] » Sun Mar 04, 2018 11:34 pm

For use in IDE *and* standalone simply make a graphic of type "polygon" and set the edit mode of it to "polygon". Then resize the object when resizing the polygon.

Needs a little bit scripting. Works like here
http://hyperhh.org/html5/SVG2PNG_HTML5- ... -4hhX.html

Come back if you take this option and get problems.

OR

add little arrows that act on your parameter fields (H, W etc).
Name these scrollbars as the fields. Script for your group:

Code: Select all

on scrollbarLineDec
  put the short name of the target into sn
  switch sn
     case "width"
       put min(400,1+fld sn) into fld sn -- adjust 400 to your maxWidth
       set width of fld buttonnumber to fld sn
       break
     case "height" ...
  end switch
end scrollbarLineDec

on scrollbarLineInc
  put the short name of the target into sn
  switch sn
     case "width"
       put max(32,-1+fld sn) into fld sn -- adjust 32 to your minWidth
       set width of fld buttonnumber to fld sn
       break
     case "height" ...
  end switch
end scrollbarLineInc
A demo for that is also at topMidth of the standalone (link above).

Here is an info how to get the source code of the standalone
http://forums.livecode.com/viewtopic.ph ... 80#p139080


p.s. (Hint) for the input in your fields change "on enterKey" to "on enterInField".
shiftLock happens

raugert
Posts: 112
Joined: Thu May 26, 2016 9:30 pm
Location: Winnipeg, Canada

Re: Resize object during runtime

Post by raugert » Mon Mar 05, 2018 6:55 am

@ hh

Thanks for the information. I've tried to apply your script to my buttons but can't seem to get it working properly. The poly graphic sets itself to the rect of the object (button), but won't allow sizing. I'm not sure if this works for resizing buttons as well as images ? The script of the poly graphic refers to "set the rect of the targetImage" :?

It seems quite complicated just for sizing an object. I'm surprised there isn't an easier way. :shock: I'll keep playing with it though, and maybe add it later on. For now I will just use the little arrows so I can move on with my project.

thanks again. I do appreciate your help.
Livecode Indy 9.6.11 (Stable)
MacOS Sonoma 14.2
Xcode 15.0.1 SDK 17.0

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9838
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Resize object during runtime

Post by FourthWorld » Mon Mar 05, 2018 7:06 am

If you can select them and see the handles but not resize them, it sounds like the lockLoc property of those controls has been set to true. Clear that and you should be fine.

If not, posting a simple stack illustrating the problem will allow us to diagnose it further.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Resize object during runtime

Post by [-hh] » Mon Mar 05, 2018 11:38 am

You see the handles and can't use them because you select the object only.
For resizing you need the pointer tool, what is very simple to have but gives problems for standalones (your scenario).

raugert wrote:It seems quite complicated just for sizing an object
Just sizing can easily be done by scrollbars (little arrows or sliders).
You wish to size by handles in browse mode.
So if you look closer at the script then you notice that the "complicated" part of it is that it allows resizing from all sides. You can shorten it easily to resizing from the bottomright.

'The targetImage' in my script is of course the object you wish to resize. You have to set that custom property in your case to the long id of the created/selected button. Sorry, I overlooked that difficulty -- the name of such a custom property can be also 'the whatYouLike'.
shiftLock happens

raugert
Posts: 112
Joined: Thu May 26, 2016 9:30 pm
Location: Winnipeg, Canada

Re: Resize object during runtime

Post by raugert » Tue Mar 06, 2018 3:08 pm

@hh

Thanks, I got your method to work OK, however, I found a much simpler way by adding the following script to the object (works for buttons and images). No need for polygram. It works nicely in IDE and standalone. :D

Code: Select all

local resize

on mouseDown b
   select me
   if item 1 of clickLoc() - item 3 of rect of me < -5 then
      grab me
   else
      put true into resize
   end if
end mouseDown

on mouseup
   put false into resize
end mouseup

on mouserelease
  put false into resize
end mouserelease

on mouseMove x, y
   if resize = true then
      put the top of me into myTop
      set the height of me to (the height of me - (the bottom of me -item 2 of mouseLoc() ))
      set the top of me to myTop
      put the left of me into myLeft
      set the width of me to (the width of me - (the right of me -item 1 of mouseLoc() ))
      set the left of me to myLeft
   end if
end mouseMove
thanks again for your suggestions.
Livecode Indy 9.6.11 (Stable)
MacOS Sonoma 14.2
Xcode 15.0.1 SDK 17.0

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9838
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Resize object during runtime

Post by FourthWorld » Tue Mar 06, 2018 3:37 pm

The "grab" command works great for moving things, but if you want to also resize them see the "choose" tool command in the Dictionary, where in addition to the pointer tool you can learn about the other tool modes available in the language.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Resize object during runtime

Post by bogs » Tue Mar 06, 2018 4:07 pm

I think his code is doing a grab based on where the mousedown hits, Richard, otherwise it goes to the resize handler he has.
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9838
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Resize object during runtime

Post by FourthWorld » Tue Mar 06, 2018 4:37 pm

Thanks, Bogs. One more thing to hate about flat design: on my phone the mouseup handler filled the box neatly, and since it's become common to not show scrollbar thumbs unless actively scrolling, there was no visual indication of anything below that, so I didn't think to try scrolling it.

Pretty good solution, bypasses the challenges of managing mixed tool modes.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”