setUsingNativeTitleBar() question

I have a menu bar in a DialogWindow, which uses the setUsingNativeTitleBar to get a native look on all platforms.

If I click on a menu item, the menu appears, but if I click on the top of the window and move the window, instead of disappearing, the menu floats in place while the window under it moves freely.

I just tried setting usingNativeTitleBar() in the juce demo, and voila! The menu disappears when you move the window with the menu showing.

So, I must be missing an important piece of code somewhere. What’s the
secret to making that work?

There’s no secret, I remember fixing it a while back so that menus disappear when you drag the titlebar, but can’t remember what was wrong before. Could be something to do with the order in which you create the window and change its title bar mode?

I let this drop for a while, but the problem is persisting. I’m calling setUsingNativeTitleBar(true); in the constructor of the main window, just as is done in the demo.

I’m not sure that setUsingNativeTitleBar() is the cause. In the demo, with that off, the window doesn’t get a click in the title bar on the first click, so I’m guessing that the menu is a modal component that is dismised by that first click outside the menu, and then the second click selects the window. With setUsingNativeTitleBar(true), the first click selects the window for a drag. Is the problem that when native, the menu isn’t a modal component, but some sort of component in the same window group?

I’ll keep investigating, but other ideas are appreciated.

A quick follow-up: this isn’t an issue under windows, only under the MacOS.

I don’t understand the problem. I tried the demo app, and it seems absolutely fine to me, regardless of title bar and menu type…?

There’s no bug in the juce demo for the mac. When you click on the title bar of the window with the menu showing, the menu closes before the window moves.

In my Mac application, the menu stays stationary and open if you click on the title bar with the menu open.

I was thinking that there was some “trick” to getting the menu to behave correctly, and disappear when the title bar of the window was clicked, but I’m not seeing it. Does the popup menu need to be set to be modal somehow?

No, like I said, there’s no trick. I really can’t think what you could be doing differently…

OK, after a little trial and error, I found the problem. It can be duplicated in the mac juce demo by changing three lines from the MainDemoWindow constructor:

setResizable(true, false);
setUsingNativeTitleBar(true);
ContentComp* contentComp = new ContentComp(this);

into

ContentComp* contentComp = new ContentComp(this);
setUsingNativeTitleBar(true);
setResizable(true, true);

I think this change creates three problems:
[list]
•Open menus in the window don’t move when the window’s title bar is moved.
•If the window is not centered on the screen and is resized, the window jumps to the center of the screen as it’s resized.
•If setResizable(true, true) is changed to setResizable(true, false), the window will not be resizable. (Perhaps this is by design on the Mac, since mac windows only resize from the lower right, but that’s not clear in the header file.)
[/list]

Ok, I tried that, and still no problems here. Are you using the latest version?

I’m still using 1.41, so the bug might have been fixed between there and 1.44

ah well, yes. Almost certainly.

I’m going to reopen this because I’m still seeing the problem under juce 1.45 It happens with any popup menu in my interface, only on mac. If I setNativeTitleBar(true), then it seems that my component doesn’t hear about the clicks, and thus the popup menus aren’t closed.

If I don’t set the title bar to be native, then some event from a click in the title bar tells the open menus to close.

If the title bar is native, how does the juce interface get informed of clicks in the title bar? That seems like where I should start my search for the cause.

Oh, the juce demo works fine, with either type of title bar, so the problem isn’t there, it must be in my code.