Re: Shape Selection
- From: "Maarten Wiltink" <maarten@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 9 Aug 2005 08:36:47 +0200
<cybatech@xxxxxxxxxxxxx> wrote in message
news:lh1gf15a7tbhfcpkccnuthai8pbnjeifsd@xxxxxxxxxx
> Hi Guts, Tiz me again.
> I have managed to create shapes at runtime and move them Ala drag,
> also I can now change there colors, but when I create more then one I
> can only change the color of the last one created. I cannot change the
> color of Previously created shapes.
<snip code>
That's because you are trampling all over the global variable Selection
in your Create_ShapeClick handler. Any shape created ends up pointed to
from Selection, effectively making it the selection. That's not at all
bad in itself, although I would have updated the display to reflect the
change of selection. You can reread ReleaseShape to see what's involved
in that.
It appears that ReleaseShape is no longer in use; you have a new method
MouseUpOnShape, which doesn't concern itself with the selection. That
would prevent you from changing the colour of previously created shapes
alright. The Selection field was introduced to save state from one
event handler to another one. It is in effect a global variable and you've
just discovered why people don't like them: forgetting to treat them
correctly in one location will break code in another location.
If you'd like to, you can chain event handlers. Just call one from the
other like a regular method. You could also have added your own code to
the existing event handler. Is there any reason why you thought you
needed to ditch existing, working, code and start from scratch?
Groetjes,
Maarten Wiltink
.
- References:
- Shape Selection
- From: cybatech
- Shape Selection
- Prev by Date: Re: Shape Selection
- Next by Date: Re: Shape Selection
- Previous by thread: Re: Shape Selection
- Next by thread: Re: Shape Selection
- Index(es):
Relevant Pages
|