Hi,
Is it possible to manipulate the x & y coordinates of the variable reporter blocks, when they are selected in the Variables display area and subsequently displayed on the screen ?
Given the various nice display formats, I'd like to use them as value labels for some sprite properties. As such,it would be helpful to programatically position them on the screen.
I repeat, watchers are not first class in Snap!. You can find one in Javascript, but only for use in Javascript. So, here's what you do:
Make a variable with a visible watcher.
Shift-click the Snap! logo and enter dev mode.
Right-click on the watcher, and find the thing in the menu that looks like the right thing, in this case a WatcherMorph. (There's more than one thing because when you clicked on the watcher you were also clicking on the stage, which is part of the entire Snap! window.) Then, in submenu, choose "Inspect."
Then go rooting around in the inspector until you find what you're looking for. In this case it's "bounds."
The notation x@y isn't obvious, but it's how a point is represented in an inspector.
You can find out more by clicking the "inspect" button at the bottom, then choose whether to start a new inspector or recycle the existing one.
"Origin" is the bottom left corner and "corner" is the top right corner. Or maybe it's top left and bottom right; I have no idea whether Y grows upward, as in math, or downward, as in (most) programming languages.
Now you can play with it in your JS block:
this.findVariableWatcher("foo").bounds.origin = new Point(0,0);
I haven't actually tried that -- I'm just guessing. But, guessing is fine. Experiment.
try return this.findVariableWatcher(varName)
What you had previously was a string, so it only looked for a watcher called varName
Using the varName parameter will look for whatever name you give to it
Thanks a lot for the tutorial and samples. Even though I am not much of a JS person, I was able to follow and use the examples. And in the meantime, I have learned a lot about the hidden world behind the blocks. I am excited that I can manipulate things on the screen beyond what SNAP offers.
I used your method and tried out the method I already had hand found that my method actually works better. here it is (I didn't do it because I don't know anything about JS)