andlabs / andlabs/libui

MacOSX menu item Quit not working

Open
#501 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
10.9k
Forks
612
PR merge metrics
No merged PRs in 30d

Description

Hi,

First of all, I'd like to say thanks for this amazing library! I've used it in my cross-platform project:
https://gitlab.com/bztsrc/usbimager
which is an extremely small (ca. 256k) compressed disk image writer with a minimalistic GUI. I use libui for Cocoa and for GTK under Linux.

I had issues with linking the provided examples under Windows, so I gave up on that part and implemented win32 myself. Any reason why you've used C++ there instead of C? Just curious, off topic.

I also had some other issues under MacOSX, mostly with multiple threads and progressbars, but I was able to solve them all. There's one thing left though, which is kept reported over and over again. Under MacOSX the menu contains a grayed out Quit and the Cmd+Q shortcut does not work either.

I took a deep dive in the source, and I've found https://github.com/andlabs/libui/blob/master/darwin/menu.m#L176 which looks okay to me and also has the keybinding set. Yet Quit is not working. I don't use multiple windows, I don't need user defined menu items, nothing extra. I've found a ticket on the Go version with exactly the same problem, and it was closed pointing to issue #321. However there's no explanation in that issue on how to enable Quit.

So may question is, what I'm doing wrong? How should I change the code to have a working Quit menu item? Here's my code: https://gitlab.com/bztsrc/usbimager/-/blob/master/src/main_libui.c#L440

Do I need some special option or something? (However I did not see any "if"s in "makeMenubar" nor in "buildApplicationMenu"). If I need to add a Quit item manually, how can I do it? "uiMenuAppendQuitItem" requires an uiMenu pointer, but I don't want to call "uiNewMenu", as it has to be added to the already existing application menu. What is the correct way to do this?

Thanks for this awesome library,
bzt

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.