Hello everyone,

I had to understand how menus work in Morphic lately and I noticed some
things :

1) When a menu has strictly more than 1 submenu active it cannot regain the
focus if the mouse doesn't pass over the submenus first. It is a bit hard
for me to explain so I will give you an example :
Open a Nautilus browser on any package and right click on a class. Now
browse "Refactoring => Code Rewriting => Rewrite Code but don't click on
any of these items. You will have 3 menus. Now if you exit the last menu
without returning to the previous one (make a loop from the right for
example if you have enough place) and go back directly to the first one
you'll see that it doesn't respond (it is like frozen).

I don't know if it is a bug or if it is intended but I find it strange as
it is not how it is working on Windows nor Ubuntu for example.

So if it is indeed a bug, what I propose as a "fix" would be this:

Replace

*:*
>
> *MenuItemMorph >>* *activateOwner Menu: evt*
>     "Activate our owner menu; e.g., pass control to it"
>     owner ifNil:[^false]. "not applicable"
>     (owner fullContainsPoint: evt position) ifFalse:[^false].
>     owner activate: evt.
>     ^true
>

by:

*MenuItemMorph >>* *activateOwner Menu: evt*
>


>
> *    | popUpOwner |*
>
> *    owner ifNil: [^false].*
>
> *    (owner fullContainsPoint: evt position) ifTrue: [*
>
> *        owner activate: evt.*
>
>
>
> *        ^true.    ].*
>
> *    popUpOwner := owner popUpOwner.*
>
> *    [ popUpOwner ] whileNotNil: [*
>
> *        (popUpOwner owner fullContainsPoint: evt position) ifTrue: [*
>
> *            popUpOwner owner activate: evt.*
>
>
> *            ^true.        ]*
>
> *        ifFalse: [*
>
>
>
> *            popUpOwner := popUpOwner owner popUpOwner.        ].    ].*
>
> *    ^false.*
>

It should work with any number of submenus but i couldn't find anywhere in
Pharo with more than 3 menus so i couldn't test it further.

2) When you leave a submenu and quickly come back to its popUpOwner, the
item in the submenu won't be deselected. So if you navigate a bit in the
menu and then want to come back to this submenu, you won't be able to
select the item by passing your mouse over it. It is not a big deal in
99.9% of the time as you will still be able to click on it but when this
item is supposed to open a submenu it won't. You need to go to another item
in the submenu and to come back.

I noticed that it happened because if you are leaving the submenu too
quickly there is no "mouseLeave" event generated so the itemMenu is not
deselected. Thus, as it is considered as selected, if you come back to it
later a "mouseEnter" event will not trigger anything.

It is quite easy to reproduce with the same menu than for the 1) :
Right click on a class in a Nautilus browser then browse Refactoring =>
Code Rewriting.
Now if you quickly come back to Refactoring sometimes you'll see that Code
Rewriting won't be deselected (it will still be blue after the 500ms time
out). If it is the case you can go back on "Rename..." and then if you
quickly come back to Refactoring => Code Rewriting, you won't be able to
get the 3rd submenu.

I can reproduce this very easily but it is not really a problem because it
only happens if you are fast with your mouse.

I did not try to fix it but I guess that reinitializing all the itemMenus
to unselected when poping a menu could do the trick.

3) This one is mostly insignificant because it is quite hard to reproduce
and doesn't trigger often at all. But sometimes when you quickly navigate
between 3 menus (I have not been able to reproduce it with only 2 menus)
when you want to go back to the first one it freezes and it doesn't handle
the mouseOver events anymore (you can still click though).
This is not the same thing than the first point because here you correctly
pass through the previous submenus to go to the first one.
I don't really know why this happens sometimes but I think it may be
because the focus was not passed quickly enough between windows and one on
the submenus gets deactivated and removed from the world wheras it still
had the focus on him.

Anyway these 3 things are not really important but I just wanted to share
what i found with you in case you think it is valid.

Cheers,

Matthieu

Reply via email to