Page 1 of 2
Resize object during runtime
Posted: Sun Mar 04, 2018 4:55 pm
by raugert
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..
Re: Resize object during runtime
Posted: Sun Mar 04, 2018 7:54 pm
by richmond62
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.
Re: Resize object during runtime
Posted: Sun Mar 04, 2018 7:58 pm
by FourthWorld
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?
Re: Resize object during runtime
Posted: Sun Mar 04, 2018 8:17 pm
by bogs
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.
Re: Resize object during runtime
Posted: Sun Mar 04, 2018 8:43 pm
by richmond62
Being able to add objects might constitute something like programming: difficult to say.
Re: Resize object during runtime
Posted: Sun Mar 04, 2018 9:01 pm
by richmond62
If I grab the corner handles
I'm obviously missing something as I can see no "corner handles" on an object in a standalone.
Re: Resize object during runtime
Posted: Sun Mar 04, 2018 10:18 pm
by raugert
@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,
Re: Resize object during runtime
Posted: Sun Mar 04, 2018 11:34 pm
by [-hh]
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".
Re: Resize object during runtime
Posted: Mon Mar 05, 2018 6:55 am
by raugert
@ 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.

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.
Re: Resize object during runtime
Posted: Mon Mar 05, 2018 7:06 am
by FourthWorld
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.
Re: Resize object during runtime
Posted: Mon Mar 05, 2018 11:38 am
by [-hh]
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'.
Re: Resize object during runtime
Posted: Tue Mar 06, 2018 3:08 pm
by raugert
@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.
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.
Re: Resize object during runtime
Posted: Tue Mar 06, 2018 3:37 pm
by FourthWorld
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.
Re: Resize object during runtime
Posted: Tue Mar 06, 2018 4:07 pm
by bogs
I think his code is doing a grab based on where the mousedown hits, Richard, otherwise it goes to the resize handler he has.
Re: Resize object during runtime
Posted: Tue Mar 06, 2018 4:37 pm
by FourthWorld
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.