Resize object during runtime
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Resize object during runtime
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
MacOS Sonoma 14.2
Xcode 15.0.1 SDK 17.0
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Resize object during runtime
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.
simplified programming with a standalone, and that is not permitted.
-
- VIP Livecode Opensource Backer
- Posts: 9838
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Resize object during runtime
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?
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Resize object during runtime
I don't know thatrichmond62 wrote: ↑Sun Mar 04, 2018 7:54 pmThis sounds like you are going to be letting end-users do some sort of
simplified programming with a standalone, and that is not permitted.
would equal programming or creating an IDE, necessarily.
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Resize object during runtime
Being able to add objects might constitute something like programming: difficult to say.
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Resize object during runtime
I'm obviously missing something as I can see no "corner handles" on an object in a standalone.If I grab the corner handles
Re: Resize object during runtime
@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,
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
MacOS Sonoma 14.2
Xcode 15.0.1 SDK 17.0
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Resize object during runtime
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:
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".
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
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
Re: Resize object during runtime
@ 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.
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.
Livecode Indy 9.6.11 (Stable)
MacOS Sonoma 14.2
Xcode 15.0.1 SDK 17.0
MacOS Sonoma 14.2
Xcode 15.0.1 SDK 17.0
-
- VIP Livecode Opensource Backer
- Posts: 9838
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Resize object during runtime
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.
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Resize object during runtime
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).
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'.
For resizing you need the pointer tool, what is very simple to have but gives problems for standalones (your scenario).
Just sizing can easily be done by scrollbars (little arrows or sliders).raugert wrote:It seems quite complicated just for sizing an object
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
Re: Resize object during runtime
@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.
thanks again for your suggestions.
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
Livecode Indy 9.6.11 (Stable)
MacOS Sonoma 14.2
Xcode 15.0.1 SDK 17.0
MacOS Sonoma 14.2
Xcode 15.0.1 SDK 17.0
-
- VIP Livecode Opensource Backer
- Posts: 9838
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Resize object during runtime
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Resize object during runtime
I think his code is doing a grab based on where the mousedown hits, Richard, otherwise it goes to the resize handler he has.
-
- VIP Livecode Opensource Backer
- Posts: 9838
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Resize object during runtime
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.
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
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn