Bert Freudenberg wrote:
Look into class PianoKeyboardMorph, specifically #buildKeyboard. It
builds each key as a separate Morph and uses #on:send:to:withValue:
to wire events.
As far as I can make out this is a way to delegate sensor events to some other object. They fire only if the object receiving the event does not handle it. I tried it with mouseDown which my digit morph does not use and it fires, with mouseOver which it does use it's handled so doesn't fire. I could potentially use this to handle handleKeystroke so delegate the parent to managing the mouse wheel. However, that gives me an error when I try it. What I really want to do is something like raiseEvent from my code and then 'on: myEvent send: myHandler to: self'. Is there no equivalent to raiseEvent in Morphic?
- Bob
- Bert -
Am 07.11.2005 um 22:18 schrieb Bob.Cowdery@CGI-Europe.com:
Now I need to know how to do user defined events such
that when a digit overflows or underflows the next digit in line
receives an
event and can increment or decrement itself. The event can go
direct or
probably more sensible to send it to the parent which is my top level
display class not the alignment morph. Any hints appreciated.
Chris Muller wrote:
I don't know whether I correctly understand what you are trying
to do, but one
suggestion would be to maintain a pure domain (the single number)
and just let
the UI display each digit..
Ok, but the reason I have a separate Morph for each digit is that
it makes the mouse interaction a lot easier to do as I mouse over
each morph, highlight it and let it capture the wheel/keystrokes.
The parent will have the single domain number and can load the
digits initially and be informed when one changes. What I am after
is understanding the morphic event system or perhaps just an event
system. Not from the point of view of events generated from the
mouse, keyboard etc but in code when I decide there is something
another object might need to know about. At the moment I give the
object a block to execute which is really little more than a
callback to execute when a certain condition is met, so an empty
block evaluates to nil and nothing happens. This is the wrong way
to do it and I want to make it a pure event system. The sender of
the event should not be concerned who the receivers are or even if
there are any receivers.
It's easy enough to code up a notifier class such that senders just
send their named events to a notifier instance and event listeners
register their interest in named events and then receive those
events. At least it's easy in languages I know, I am still
struggling a bit with the syntax and class library. I simply
thought that there must be a class that does that somewhere.
*** Confidentiality Notice *** Proprietary/Confidential Information belonging to CGI Group Inc. and its affiliates may be contained in this message. If you are not a recipient indicated or intended in this message (or responsible for delivery of this message to such person), or you think for any reason that this message may have been addressed to you in error, you may not use or copy or deliver this message to anyone else. In such case, you should destroy this message and are asked to notify the sender by reply email.
Hello Bob,
BCCEc> an error when I try it. What I really want to do issomething BCCEc> like raiseEvent from my code and then 'on: myEvent send: BCCEc> myHandlerto: self'. Is there no equivalent to raiseEvent in BCCEc> Morphic?
not a direct reply and I'm not sure about your smalltalk background, but what you describe seems to call for good old dependency mechanism.
Be aware, that my impression is prominent squeakers seem to prefer different solutions, (dunno which, too new myself) but no one seems to reply.
Cheers,
Herbert mailto:herbertkoenig@gmx.net
Am 08.11.2005 um 15:33 schrieb Bob.Cowdery@CGI-Europe.com:
Bert Freudenberg wrote:
Look into class PianoKeyboardMorph, specifically #buildKeyboard. It builds each key as a separate Morph and uses #on:send:to:withValue:
to wire events.
As far as I can make out this is a way to delegate sensor events to some other object. They fire only if the object receiving the event does not handle it. I tried it with mouseDown which my digit morph does not use and it fires, with mouseOver which it does use it's handled so doesn't fire.
That is correct - if you choose to override the default behavior in your morph you're on your own (unless you call super's version of the mouse over handler, which would allow the on:send:to: mechanism to continue to work).
I could potentially use this to handle handleKeystroke so delegate the parent to managing the mouse wheel. However, that gives me an error when I try it. What I really want to do is something like raiseEvent from my code and then 'on: myEvent send: myHandler to: self'. Is there no equivalent to raiseEvent in Morphic?
See the categories named "event-..." in class Object. There are usage examples in classes EventTest and EventManagerTest. Basically, use #when:send:to: to register a handler and #triggerEvent: to trigger the event.
A special problem is that #when:send:to: has nothing to do with #on:send:to: (which is older), which again has nothing to do with the even older #changed/#update mechanism. However, all of these are used in places, and there are even more obscure notification mechanisms in the image. Also, all of them are synchronous (a weakness only solved in Tweak AFAIK).
- Bert -
squeak-dev@lists.squeakfoundation.org