I understand that a shape is shared by elements but what I do not is why ?For exampleshape := RTBox new color: Color red.els := shape elementsOn: (1 to: 10).els do: [ :e |e on: TRMouseLeftClick do: [ :event | e shape color: Color random. e update. view signalUpdate ].In this example if I change an element with a left click its color will change so it is ok.e on: TRMouseRightClick do: [ :event | e shape borderColor: Color random. e update. view signalUpdate ]]But after, I change the border color wiht a right click, the border will be change AND the color too. But I did not want that, just the border.Do you see my point ? I do not understant why shape should be shared ?_______________________________________________On Wed, Jul 2, 2014 at 10:26 PM, Alexandre Bergel <alexandre.bergel@me.com> wrote:
Hi Leo,
Sorry to reply so late.
Your script does exactly what it is supposed to do. Maybe part of the shape semantic is not clear.
Consider this part of the script:
You click on an element e, which means you change the shape of the element. You update the element itself, it therefore changes its color. But with "els atRandom update” you also update another element. Since the shape is shared by all the elements, the behavior is indeed correct.
> e on: TRMouseClick do: [ :event |
> e shape color: Color random. e update. els atRandom update. view signalUpdate ]
A shape is shared with all the objects. What is not shared are Trachel shapes.
You have the following relations:
shape := RTBox new size: 10.
e1 := shape elementOn: 'hello'.
e2 := shape elementOn: 'world'.
self assert: e1 shape == e2 shape.
self assert: e1 shape ~~ e1 trachelShape.
self assert: (e1 shape isKindOf: RTBox).
self assert: (e1 trachelShape isKindOf: TRBoxShape).
self assert: e1 trachelShape ~~ e2 trachelShape.
Let me know if something is not clear. I have written this in the class comment of RTShape.
Cheers,
Alexandre
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
On Jun 25, 2014, at 5:37 AM, Leo Perard <leo.perard@gmail.com> wrote:
> Hi,
>
> I'm not sure it is but I think I have found a bug where elements share the same instance of a shape.
>
> Here an example:
>
> view := RTView new.
>
> els := (RTBox new size: 20) elementsOn: (1 to: 10).
> view addAll: els.
>
> els do: [ :e |
> e on: TRMouseClick do: [ :event |
> e shape color: Color random. e update. els atRandom update. view signalUpdate ]
> ].
>
> RTHorizontalLineLayout on: els.
> view open
>
> It should only change the color of one element but it doesn't.
> So I don't know if it is wanted or not.
> --
> Cheers,
> Leo Perard
> University of Lille 1
> _______________________________________________
> Moose-dev mailing list
> Moose-dev@iam.unibe.ch
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev
_______________________________________________
Moose-dev mailing list
Moose-dev@iam.unibe.ch
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
--Cheers,Leo PerardUniversity of Lille 1
Moose-dev mailing list
Moose-dev@iam.unibe.ch
https://www.iam.unibe.ch/mailman/listinfo/moose-dev