Location Location
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Location Location
I want to set the location of a field but am thwarted by
the Dictionary....
Can't find the relevant info anywhere else...
the Dictionary....
Can't find the relevant info anywhere else...
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
Re: Location Location
Do you get any errors if you
or is it just the dictionary that is confusing you?
The dictionary mentions location (can be abbreviated to loc) referring to "an object" which definition includes a field. It gives a few examples of other objects, but those aren't the only ones applicable. If the field won't move to the correct place if you set its loc, there must be something else affecting it. In the property inspector is the can't modify checkbox hilited? Or on the sizing pane of the pi is the size and location locked?
Code: Select all
set the loc of field "myField" to 100,100
The dictionary mentions location (can be abbreviated to loc) referring to "an object" which definition includes a field. It gives a few examples of other objects, but those aren't the only ones applicable. If the field won't move to the correct place if you set its loc, there must be something else affecting it. In the property inspector is the can't modify checkbox hilited? Or on the sizing pane of the pi is the size and location locked?
Re: Location Location
Have a look at the pic and note that the bottom lines
of the text are obscured by the "User Input" field
even though the scroll-bar is fully down.
of the text are obscured by the "User Input" field
even though the scroll-bar is fully down.
Is age an excuse? Eighty-four and counting.
Programming powered by coffee.
Programming powered by coffee.
Re: Location Location
Hm, that is odd. If you don't mind, could you tell me which version you have doing that?
In any case, here is the complete reference for location:
It should give you the complete entry, as I did here.
Hope that helps
In any case, here is the complete reference for location:
Something else that may help if you encounter this again in the future, open any text editor, click inside the dictionary pane where the entry is, press [ctrl + c] (or your os's combo for copy), then go to the text editor and press [ctrl + v] (or your os's combo for paste).location
Type: property
Syntax:
set the location of object to point
Objects (or Types): card,stack,group,field,button,graphic,scrollbar,player,image
Synonyms:
loc
See Also: move Command, revChangeWindowSize Command, screenLoc Function, moveStack Message, topRight Property, windowManagerPlace Property, controlAtLoc Function, controlAtScreenLoc Function
Introduced: 1.0
Platforms: Desktop, Server, Web and Mobile
Supported Operating Systems: Mac, Win, LIn, ios, Android
Summary:
Specifies where an object is.
Examples:
if the location of button 1 is within the rect of field 1 then selectIt
set the location of this stack to the mouseLoc
Use the location property to move an object without resizing it, or to find out where an object is.
Value:
The location of an object is any expression that evaluates to a point--two integers separated by a comma.
The first item of the location is the distance in pixels from the left edge of the screen (for stacks) or card (for other objects) to the center of the object. The second item is the distance in pixels from the top edge of the screen (for stacks) or card (for other objects) to the center of the object.
For cards, the location property is read-only and cannot be set.
Comments:
The location of a stack is in absolute (screen) coordinates. The first item of a card's location property is equal to the width of stack div 2; the second item is is equal to the height of stack div 2. The location of a group or control is in relative (window) coordinates.
In window coordinates, the point 0,0 is at the top left of the stack window. In screen coordinates, the point 0,0 is at the top left of the screen.
Changing the location of an object moves it to the new position without resizing it. To change an object's size, set its height, width, or rectangle properties.
It should give you the complete entry, as I did here.
Hope that helps
Re: Location Location
I know I am probably missing something extremely simple in all this, but after reading that entry I thought I could stick the closing location of the stack into a custom property, and then have the app re-open at its last location (usually I use pref files for this sort of thing, but what the heck, I wanted to try something I thought would be simple to explore custom props!).
In card 1 of the main stack, I put :
Stack "Report" is a substack of my main stack, so if I understand how stacks work correctly, I should be able to write the custom prop. there and it will persist through closing and opening the program. In the IDE this does indeed happen, and it lists the x / y coordinates of the program.
Next, in card 1 I added this, based on this line from the dictionary "set the location of this stack to the mouseLoc", reasoning that if it would use the x / y of the mouseLoc, it would also use the x / y of the cust. prop. :
However, this produced an error on re-opening the stack:
error "card "frmMain": execution error at line n/a (Object: coordinate is not a point) near myCustLocProp
Undaunted, I tried a few more variations to see if I could figure out what was going wrong on my own. First, I tried reading in the 2 items of the cust. prop. :
This gave me the same error, now referencing tmpX1 and tmpX2
error "card "frmMain": execution error at line n/a (Object: coordinate is not a point) near "tmpX1, tmpX2"
I tried a few variations of the above two examples, with and without (), "", (""), and so on. To make sure the cust. prop. had the right info, I moved the program around and closed it, and the numbers do appear to record correctly. When opening it however, it always produces that error, then if you hit stop or continue, the program shows up at the last position indicated by the cust. prop. (figures), but not in the standalone.
Any ideas on what I'm missing?
In card 1 of the main stack, I put :
Code: Select all
on closeStack
// set the last open location of the stack...
set myCustLocProp of the stack "Report" to the location of the defaultStack
end closeStack
Next, in card 1 I added this, based on this line from the dictionary "set the location of this stack to the mouseLoc", reasoning that if it would use the x / y of the mouseLoc, it would also use the x / y of the cust. prop. :
Code: Select all
on openStack
// put the stack at the last open position...
set the location of this stack to myCustLocProp of stack "Report"
end openStack
error "card "frmMain": execution error at line n/a (Object: coordinate is not a point) near myCustLocProp
Undaunted, I tried a few more variations to see if I could figure out what was going wrong on my own. First, I tried reading in the 2 items of the cust. prop. :
Code: Select all
put item 1 of myCustLocProp into tmpX1
put item 2 of myCustLocProp into tmpX2
set the location of this stack to ("tmpX1, tmpX2")
error "card "frmMain": execution error at line n/a (Object: coordinate is not a point) near "tmpX1, tmpX2"
I tried a few variations of the above two examples, with and without (), "", (""), and so on. To make sure the cust. prop. had the right info, I moved the program around and closed it, and the numbers do appear to record correctly. When opening it however, it always produces that error, then if you hit stop or continue, the program shows up at the last position indicated by the cust. prop. (figures), but not in the standalone.
Any ideas on what I'm missing?
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Location Location
This may be the cause, after a quick read.
You really ought always to use "the" when dealing with properties.
You can, it seems, get away with:
On another note, you do not ever need to say "...of the stack...". You only need to say "...of stack..." This is a matter of style, in that LC accepts the superfluous "the" in that particular construction, but I recommend against it. I just don't like it.
Craig Newman
You really ought always to use "the" when dealing with properties.
You can, it seems, get away with:
when setting a property, but you cannot get away with:set myCustLocProp of the stack "Report" to the location of the defaultStack
The fix is always to: "set the custProp of..." and (critically) "get the custProp of..." In other words always include "the".set the location of this stack to myCustLocProp of stack "Report"
On another note, you do not ever need to say "...of the stack...". You only need to say "...of stack..." This is a matter of style, in that LC accepts the superfluous "the" in that particular construction, but I recommend against it. I just don't like it.
Craig Newman
Re: Location Location
Thank you for that bit of information Craig, it was a very helpful piece I didn't have previously.
I had already tried using "the" in front of the cust. prop. (but didn't know its importance, and forgot to mention it up there among the things tried). It does remove the error in the IDE, but when saved into a standalone it still doesn't actually use the property. I have further tested to see that it was getting stored using the answer statement, it does pop up the different locations the program is moved to.
After confirming that I now have the "the" in front of the property, I tried moving the line calling it to different locations and testing (preOpenStack, openStack, etc. ). No love was found
I then changed tactics and tried putting the missing "the" back into this code :
figuring that it was a straight forward 2 point location at that point, but still no love.
I think the next thing I'll do is create a new stack and test it in something I don't have a lot of other code bouncing around in.
I had already tried using "the" in front of the cust. prop. (but didn't know its importance, and forgot to mention it up there among the things tried). It does remove the error in the IDE, but when saved into a standalone it still doesn't actually use the property. I have further tested to see that it was getting stored using the answer statement, it does pop up the different locations the program is moved to.
After confirming that I now have the "the" in front of the property, I tried moving the line calling it to different locations and testing (preOpenStack, openStack, etc. ). No love was found
I then changed tactics and tried putting the missing "the" back into this code :
Code: Select all
put item 1 of the myCustLocProp into tmpX1
put item 2 of the myCustLocProp into tmpX2
set the location of stack "Timer" to tmpX1, tmpX2
I think the next thing I'll do is create a new stack and test it in something I don't have a lot of other code bouncing around in.
Re: Location Location
To what object is the myCustLocProp attached?
You need to specify what object it is a custom property of.
You need to specify what object it is a custom property of.
Re: Location Location
Sorry about the mix up, the code above was incomplete. The actual code I attempted was:
However, while no errors are generated in the IDE, it does not appear to work in the standalone.
Still waiting to get back to it in a new project, clean of any code.
Code: Select all
put item 1 of the myCustLocProp of stack "Report" into tmpX1
put item 2 of the myCustLocProp of stack "Report" into tmpX2
set the location of this stack to tmpX1, tmpX2
Still waiting to get back to it in a new project, clean of any code.
Re: Location Location
Hi bogs,
You will need to save all your data outside of the standalone, mabe in
specialfolderpath("documents")
specialfolderpath("preferences")
or somewhere else, where your app/exe has write permissions.
Best
Klaus
don't forget that standalones (the standalone/mainstack and its substacks) CANNOT save themselves!bogs wrote:...
However, while no errors are generated in the IDE, it does not appear to work in the standalone.
...
You will need to save all your data outside of the standalone, mabe in
specialfolderpath("documents")
specialfolderpath("preferences")
or somewhere else, where your app/exe has write permissions.
Best
Klaus
Re: Location Location
Heya Klaus !
I thought that you *could* save information in substacks of the standalones? Will look at the lessons again to see if maybe I mis-read it, but I was sure thats what it said
** edit **
Klaus, BOY is my face red ! I completely failed to parse this lesson correctly. After much reading of similar information, THIS article snapped it into my head a tad more clearly.
So, to sum up, what I think I get now is that you *can* save (probably everything) in a substack, as long as it is saved as a separate file from the standalone application AND the user has write permissions in that directory (/home/user, special folder documents, etc.).
Oh well, at least I learned some about custom properties (Now I have to go change my edit in Max's wiki )
I thought that you *could* save information in substacks of the standalones? Will look at the lessons again to see if maybe I mis-read it, but I was sure thats what it said
** edit **
Klaus, BOY is my face red ! I completely failed to parse this lesson correctly. After much reading of similar information, THIS article snapped it into my head a tad more clearly.
So, to sum up, what I think I get now is that you *can* save (probably everything) in a substack, as long as it is saved as a separate file from the standalone application AND the user has write permissions in that directory (/home/user, special folder documents, etc.).
Oh well, at least I learned some about custom properties (Now I have to go change my edit in Max's wiki )
Last edited by bogs on Thu Jun 08, 2017 9:59 pm, edited 1 time in total.
Re: Location Location
No, if a stack is part of the standalone file (ie a substack) you cannot write to it. You can use the "splashstack" technique of having a standalone which is simply a launcher for a separate stack, which can be written to and saved.
Re: Location Location
Thank you SparkOut, for confirming my findings for me, confirmations always a good thing
Now if I could get smarter faster ...
Now if I could get smarter faster ...