Problem with RibbonMouseSensor.cs and HittedItem for Minimized ribbons

Nov 5, 2014 at 10:20 PM
Edited Nov 6, 2014 at 1:40 AM
The code in RibbonMouseSensor.cs doesn't adequately protect against checking minimized items. HitTest will set the HittedItem to an item which is on a minimized tab. To see this in action, put a click event handler on cut or paste in the clipboard panel of the START tab in MainForm in the demo code. Then run the demo. Minimize the ribbon and click just to the right or left of the START tab. It will fire the click event handler for the hidden cut or paste items. If you set a breakpoint at RibbonMouseSensor.cs line 741, you will see the HittedItem being set to item when moving the mouse around on a minimized tab.

Not sure if this is the best fix but I added an if statement in my code and it resolved the problem:
if (item.Bounds.Contains(p))
    // if statement added to workaround bug with clicks firing on minimized tab items
    if (!(item.OwnerTab != null && !Ribbon.Expanded))
        HittedItem = item; break;