Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event propagation in a Morphic GUI

I have an image for a Squeak Morphic GUI that contains some transparent parts and thus should not accept any mouseevents etc. but just be visible, but it needs to be visible in front of other morphs.

That's why i thought it would be useful to propagate the appearing mouseevents to the underlying morphs. Does anyone know a solution for my problem or another suggestion to solve it.

    V                         <- mouseDownEvent
_____________________________ <- transparent image (BorderedMorph)
  _____    _____     _____
_|     |___|    |___|     |__ <- buttons waiting for click and drop events

_____________________________ <- basic morph

i hope that illustrates my problem.

like image 525
hanneswurstes Avatar asked Jan 19 '10 14:01

hanneswurstes


2 Answers

The best thing I can think of is something along the following lines (in increasing order of smoothness, and decreasing order of likelihood to work)

  1. Record the event, tab the transparent image away, and replay the event. This seems like an inefficient and poor way of doing it.
  2. Somehow keep track of what has focus behind your transparent image, and pass the event to it. I'm not familiar with the libraries in question, so I don't know if it's possible to do it like that. If you have control over the other layers, this is most likely the way to go. (You can directly call their 'a mouse event happened' functions with that mouseDownEvent, though you do still have to identify which one would receive it).
  3. Simply declare it as something that doesn't get mouse events passed to it at whatever level is available. OSD windows tend to do this, I'm not sure how. If you can do it this way, I would advise it... but given that you're asking this question, you probably can't.
like image 185
zebediah49 Avatar answered Oct 04 '22 02:10

zebediah49


By default, Morphic mouse events are handled in the top-most morph. However, a parent morph is able to intercept #mouseDown to children using #mouseDownPriority.

Your transparent image gets all clicks because it is top-most. Take a look at #rejectsEvent:. It justs combines #isLocked and #visible to reject events. You may want to override this in order to reject events even if visible.

For example:

MyMorph>>rejectsEvent: anEvent
  ^ true "Ignores all events."
like image 44
Marcel Taeumel Avatar answered Oct 04 '22 03:10

Marcel Taeumel