Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: JUCS Titlebar close button non-functional in Windows #1469

Open
1 task done
Kirsten-Hobby opened this issue Nov 10, 2024 · 8 comments
Open
1 task done

[Bug]: JUCS Titlebar close button non-functional in Windows #1469

Kirsten-Hobby opened this issue Nov 10, 2024 · 8 comments

Comments

@Kirsten-Hobby
Copy link

Detailed steps on how to reproduce the bug

I am using JUCE titlebar for main app (document window) & for modal dialog windows. The close button does not function so there is no way to close the main app window. If I change a modal dialog to Native (Windows) then that close button works. Bug exists in both 8.0.3 & develop branches

What is the expected behaviour?

Close button should close window

Operating systems

Windows

What versions of the operating systems?

Windows 10 Pro 22H2

Architectures

64-bit

Stacktrace

No response

Plug-in formats (if applicable)

VST3, Standalone

Plug-in host applications (DAWs) (if applicable)

No response

Testing on the develop branch

The bug is present on the develop branch

Code of Conduct

  • I agree to follow the Code of Conduct
@reuk
Copy link
Member

reuk commented Nov 18, 2024

I'm currently unable to reproduce this behaviour in testing.

Please can you provide some more detail about the exact steps you're taking in order to trigger the issue? Ideally, share a minimal code example that demonstrates the problem, or explain how to trigger the issue in one of the JUCE examples from the main repository.

In particular, it's not clear which close button is not working - the modal dialog's close button, or the main window's button.

I tried modifying a standalone plugin project to use a non-native titlebar for the Audio/MIDI settings window by changing line 313 of juce_StandaloneFilterWindow.h like so:

        o.useNativeTitleBar             = false;

The behaviour I see is as follows:

  • When I first run the standalone plugin, the close button works as expected.
  • When I run the app, then click "options -> Audio/MIDI Settings..." to open the modal settings window, then:
    • All controls in the main window, including the close button, are disabled because a modal window has focus, and
    • The close button for the modal window still works as expected.
  • After closing the modal window, the close button on the main window functions normally again.

This is the behaviour I'd expect to see. Are you seeing different behaviour to this? If so, it would be helpful to test exactly the code you're running, in order to debug the issue. If you'd prefer not to share the code publicly, you can also reach us at info [at] juce [dot] com.

@Kirsten-Hobby
Copy link
Author

Kirsten-Hobby commented Nov 18, 2024 via email

@reuk
Copy link
Member

reuk commented Nov 19, 2024

If your window is fully custom, and doesn't inherit from DocumentWindow, perhaps you need to override Component::findControlAtPoint. The implementation for DocumentWindow is probably a good starting point for a custom implementation.

@Kirsten-Hobby
Copy link
Author

Kirsten-Hobby commented Nov 19, 2024 via email

@reuk
Copy link
Member

reuk commented Nov 19, 2024

Please try implementing Component::findControlAtPoint and/or deriving your custom window from DocumentWindow as I suggested above, and check whether that helps.

@Kirsten-Hobby
Copy link
Author

Kirsten-Hobby commented Nov 20, 2024 via email

@reuk
Copy link
Member

reuk commented Nov 20, 2024

How are you adding your buttons to the document window?

The DocumentWindow implementation of findControlAtPoint does the following:

for (const auto& [control, kind] : { std::tuple (getMinimiseButton(), WindowControlKind::minimise),
                                     std::tuple (getMaximiseButton(), WindowControlKind::maximise),
                                     std::tuple (getCloseButton(),    WindowControlKind::close) })
{
    if (control != nullptr && control->contains (control->getLocalPoint (this, pt)))
        return kind;
}

So, if you're adding additional buttons instead of styling the buttons that the window creates, this implementation won't work for you. You'd need to override the function yourself to do the right thing, or change your window implementation to use the buttons provided by the DocumentWindow. I recommend actually debugging into DocumentWindow::findControlAtPoint to find out why it's returning client.

@Kirsten-Hobby
Copy link
Author

Kirsten-Hobby commented Nov 21, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants