Search code examples
delphifocusribbon

Forms' focus malfunctioning when both have ribbon


I encountered yet another problem with ribbon. When I have two forms (one of them is main) and I put ribbon on both of them, they behave strangely. When I open the second form by Form2.Show;, every time I click a ribbon menu button on the second form, it loses focus and the main form gets it.

This happens at pure blank project, so what could I possibly be doing wrong?

Here is a video, just in case: Watch YT

And to be clear, the Action1 button has only Caption:='a'; code.


Solution

  • The ribbon control assumes that there is only one per application, and misbehaves if it is not the only control. You could try to modify the Ribbon.pas code, but it is doing some hacks that probably rely on Ribbon.Parent being Application.MainForm only.