[Cuis-dev] Mouse focus bad behavior

Phil B pbpublist at gmail.com
Mon Aug 19 01:57:25 PDT 2019


I'm running into a couple of situations where I am having problems with
Morphs stepping on each other re: mouse focus.  The issue is that sometimes
you might get the mouse focus directly (i.e. your method requested it by
sending #newMouseFocus:) and sometimes you get it indirectly (i.e. via
event processing where some other morph/method sent #newMouseFocus: and
even released it (setting it to nil) on your behalf that you might be
unaware of).   The result is that there doesn't appear to be a clean way to
keep track of who had the mouse focus before the current morph did and
therefore no good way to return the mouse focus when the current morph is
done with it.[1]

It would be nice if HandMorph took care of this automatically but I'm
thinking that this would create too much overhead (including a trail of
potentially defunct morphs which would have to be weakly referenced to
avoid problems further increasing overhead)  So I'm thinking that adding
the mechanism to Morph would do the trick (something along the lines of
#takingMouseFocusFrom: when the current focus is non-nil) with the
understanding (i.e. put it in the method comment of whatever the method
gets called) that it is the responsibility of any Morph taking mouse focus
to set it back to the previous owner when it is done with it.  I'll be
happy to put together a changeset for this but wanted to see if this seems
like a reasonable approach before getting going on it...

[1] If you've ever had a MenuMorph unexpectedly remain open, this is quite
possibly what caused it.  As you add Morphs which want mouse focus for
whatever reason, the odds of this becoming an issue for you increase
significantly.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20190819/87d8d72b/attachment.htm>


More information about the Cuis-dev mailing list