Has anyone tried to make a JUCE titlebar that *looks like* a native titlebar?

It seems extremely problematic to use native titlebars, given the many threads about it here.

For one, I notice that NO mouse-events (i.e. mouseDown) are generated when clicking on a native title bar. (Mac OS X)

Can anyone explain why?

Since I have need of this functionality, I’m wondering if any fruit would be borne by trying to make a custom JUCE title bar that mimics the appearance of a native title bar?

PS: I’m talking about a GUI App using DocumentWindow.

Or, is there anything I can do to get mouse clicks on a native title bar?

I think the biggest challenge in replicating titlebars will be the number of variations that you’d have to cover and the fact that there’s likely no way to ask the OS which variation to use.

Mac would probably be simpler, AFAIK there’s only a light and dark mode to implement, but on Windows you can set titlebars to have accent colours that can also be semi-transparent so replicating that would be very challenging.

2 Likes

I’m not sure what functionality you’re after beyond a mouse event, but I would suggest avoiding trying to replicate a native title bar. @ImJimmi has pointed out some issues on Windows trying to replicate it but you’ll also have to take into consideration which version of an OS you’re running on, for example, BigSur has changed the native title bar, and every time Apple or Microsoft make changes you’ll have to update to match.

It would probably be easier to do that part of your application natively. I’ve never tried it but I suspect it would be possible. Maybe it would help to explain your use case, it could be that there are alternative ways to do what you want?

1 Like

Yeah, I think it’s probably a bad idea, and you’re both right about it being a futile exercise. There’s no way you could cover all the variations…

The use case I was wrestling with at the moment: GUI App, running on Mac OSX (I haven’t tested if the same issue exists on Windows yet), with the possibility of opening more than one DocumentWindow, one containing the Main App and other windows containing additional support parameters etc.

Using native title bars, I run into this issue: Let’s say you have a Slider with a text box, or some ComboBoxes. When you click in the Slider text box to edit the value, or click in the ComboBox to focus it and pop open the menu, if you click on a native title bar of the same window or a different window, the focus is not cancelled, you do not exit the edit state of the component, the other window is not “brought to the front” thereby gaining the front window appearance, etc. You’re basically stuck in the edit state unless you cancel it some other way. (Now, if you click and drag the title bar of the native window, it does cancel out of the focused state, but that’s not the same as a simple click, which I would expect to do the same thing.)

It could just be me, but my expectation of the behavior in this case is that clicking on the title bar, especially of a different window, would cancel out of the focused component. It drives me nuts. Absolutely doesn’t happen with a JUCE title bar - because the window gains focus and cancels the component focus. But I tried and tried and you get nothing when clicking on a native title bar. No focus changes, no mouse events, nothing you can grab onto. If anyone has a JUCE hack/suggestion, I’m all ears. But I’ve not ever jumped down the “doing that part natively” rabbit hole before.