I do not understand.
you need to position points/morphs in a canvas ?
In that case you need a) a canvas and b) the points.
This cannot (and should not) be achieved with different widgets (spec)
but with just one : a morph there acts as a canvas.
So, instead of going to the window of the presenter (which,, by the way,
may or may not exist) I would just add a morph, e.g. :
(this example is just a script, in real life you would do things
differently)
presenter := SpPresenter new.
presenter layout: (SpBoxLayout newVertical
add: (morphPresenter := presenter newMorph);
yourself).
morph := Morph new color: Color white.
morphPresenter morph: morph.
morph color: Color white.
1 to: 10 do: [ :index |
| pointMorph |
pointMorph := Morph new
color: Color random;
extent: 10@10;
yourself.
pointMorph position: 300 atRandom @ 200 atRandom.
morph addMorph: pointMorph ].
presenter open.
this will give you something like this:
getting the real size of a window is not really provided by the api
except for its initial status (after that, you can suscribe to the
resize event if you want to know the new size), but you shouldn't needed
that (and getting the SpWindow which is a morph is not the way to go,
since this is not portable).
Spec is a framework to make and place **widgets**, as soon as you need
something that is not a widget, you need to go to a lower level than it
(hence, rendering a morph).
Esteban
On 17/06/2024 00:08, Haroldo Stenger wrote:
hi all there , I'm playing around with this example from the nice Spec
book, which I try to get right for spec2. That's all right. I modify
the example for having two counters, one bound to the class of the
Surveys and then one for each survey. That was a good learning
experience. Then I added a button to spawn further a Survey which
participates of the class-bound count of votes. That's all right too.
Then I started to write a method that given a Rectangle, and a number
n, gives an array of n Points that are in the enclosed circle of the
rectangle, more or less. Waht I want to achieve es that for each added
Survey, its Spec2 - Morph window gets positioned in one of these
points, but before rendering it, re position all the already existing
Spec2 - Morphs Survey windows in the rest of the points of the array
(being n the total number of Surveys after adding one). I'm facing two
challenges: (a) getting the list of current positions of Spec2 - Morph
Surveys already existing. (b) moving a Spec2 - Morph window to another
position. I'm pretty stuck trying to make my way for this two goals,
so any kind help will be really welcome. Yo can import the files into
a Pharo12 image with the File manager, then Changelist Browser and
selecting all the lines and "file in".
thanks in advance !
Haroldo