[Cuis-dev] Mouse focus bad behavior

Juan Vuletich juan at jvuletich.org
Wed Aug 21 06:00:30 PDT 2019


Hi Phil,

On 8/19/2019 5:57 AM, Phil B via Cuis-dev wrote:
> 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]

I see.

>
> 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)

Right.

> 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)

Makes perfect sense.

> 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 don't think this comment is really needed. Most morphs won't take 
mouse focus themselves, but get it from the hand. And those morphs who 
do, well, they should know what they are doing, right?

> 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...

Yes, please.

> [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.

If you see an obvious fix to MenuMorph, using your new 
#takingMouseFocusFrom, that could alleviate this issue, please go ahead!

Thanks,

-- 
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich



More information about the Cuis-dev mailing list