[Q][Connectors] Locking ends?
Ned Konz
ned at bike-nomad.com
Sun Jul 13 03:12:13 UTC 2003
On Saturday 12 July 2003 07:34 pm, German Morales wrote:
> I'm using connectors, and I was wondering if it is possible to lock
> one of the ends. That is, I want to connect one end to a Morph, and
> then forbid disconnections with the mouse.
>
> I'm already using #wantsToAttachEnd:toMorph: to avoid undesired
> connections, but for one of the ends something like
> #wantsToDettachEnd:fromMorph: would be perfect.
>
> Is there some support already in place?
No, sorry, there isn't. However, you could subclass NCConnectorMorph
if you haven't already done it.
It's easy to add, and I've just added it to my TODO list for the
upcoming version of Connectors.
Where you want to probably want to change it is in:
#mouseDownInConnected: and/or #mouseDownInOneEndConnected:, and keep
them from emitting #mouseDownNearEnd events.
Or you could copy the defaultFSM for your subclass (using a
veryDeepCopy on the superclass one) and add a new handler to it or
otherwise edit it.
I'm seriously considering changing the FSM model that the Connectors
use to something easier to browse. Right now, there's a 2-deep
IdentityDictionary structure (eventName/stateName/actions) in a
single read-only prototype FSM. I'd thought that having the FSM
tables be dynamically changeable would be useful, but I've never done
that.
In the model I'm considering, there is a 1:1 mapping between states
and methods, so handling an event is a matter of a single #perform or
MessageSend evaluation.
Of course, then the methods have to switch on event types, but that's
relatively lightweight (either via double dispatch or
#caseOf:otherwise:).
Thanks for the suggestion, though. Want to be an alpha tester?
--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE
More information about the Squeak-dev
mailing list
|