MenuBar in macOS Catalina
Re: MenuBar in macOS Catalina
Hi,
this is not a bug in wxWidgets, I believe. I had the same problem but I could solve the issue with creating a new Xcode target. Previously, I "upgraded" a command line program to wxWidgets. That worked well till Mojave. After upgrading to Catalina and Xcode this program failed with the same symptoms you have described. I added an Info.plist file but no help.
For whatever reasons the NSMenu callbacks are not called after starting the app (none of them). When bringing the app into the background and back to the foreground all callbacks are served.
Finally, I created in Xcode an App target and associated the same files and libraries (no re-compilation!) to the new target. And everything works now!
BTW: I also checked the repository and could not find any modifications regarding menus.
PS: I am using a 2019 version of wxWidgets.
this is not a bug in wxWidgets, I believe. I had the same problem but I could solve the issue with creating a new Xcode target. Previously, I "upgraded" a command line program to wxWidgets. That worked well till Mojave. After upgrading to Catalina and Xcode this program failed with the same symptoms you have described. I added an Info.plist file but no help.
For whatever reasons the NSMenu callbacks are not called after starting the app (none of them). When bringing the app into the background and back to the foreground all callbacks are served.
Finally, I created in Xcode an App target and associated the same files and libraries (no re-compilation!) to the new target. And everything works now!
BTW: I also checked the repository and could not find any modifications regarding menus.
PS: I am using a 2019 version of wxWidgets.
Re: MenuBar in macOS Catalina
Can you walk me through the basic steps to create the new target in XCode? I'm interested in trying this solution.
BeerSmith.com
Re: MenuBar in macOS Catalina
Just to report, if anyone is still concerned, that this problem persists with the updated wxWidgets 3.1.4 on macOS 10.15.6
Re: MenuBar in macOS Catalina
Hi,
I presume you did build the Application Bundle" and from the Terminal you are running it as:
(as for the minimal sample)?
Thank you.
I presume you did build the Application Bundle" and from the Terminal you are running it as:
Code: Select all
open minimal.app
Thank you.
Re: MenuBar in macOS Catalina
Yes, as per previous discussions I (we) are rebuilding 'everything' each time there's a new wxWidgets or macOS releases.ONEEYEMAN wrote: ↑Tue Aug 11, 2020 10:15 pm Hi,
I presume you did build the Application Bundle" and from the Terminal you are running it as:
(as for the minimal sample)?Code: Select all
open minimal.app
No, not running the application with 'open' from the command line, but with ./myapp [command-line-arguments]
(with myapp being a symbolic link to myapp.app/Contents/MacOS/myapp
This method has worked for many years, until this topic was first posted in this forum.
The suspicion is that macOS is not passing some initialization event to wxWidgets (since Catalina).
Thanks.
Re: MenuBar in macOS Catalina
Sorry, forgot to add - even if one invokes the program with:
open myapp.app --args -x
macOS redirects stdout and stderr (somewhere?) making it not behave like a traditional Unix program.
Re: MenuBar in macOS Catalina
Hi,
Could you try building the minimal sample and run it with:
and then check if the menu works correctly?
Please remember that Apple make it a hard requirement with Catalina to build the Application Bundle (I believe you could work without it in the past). That is according to Stefan. And so one should operate with the Bundle directly.
If "minimal" sample will work - it will be confirmed.
Also, are you doing a GUI or a console application?
Thank you.
Also, about your comment - OSX is NOT UNIX/Linux. Those are 2 completely different OSes.
So of course they are behaving differently.
But I don;t know where/how/what OSX doing when you passing an arguments to a program. But that should be for later. Right now we are trying to fix the menu under Catalina.
Could you try building the minimal sample and run it with:
Code: Select all
open minimal.app
Please remember that Apple make it a hard requirement with Catalina to build the Application Bundle (I believe you could work without it in the past). That is according to Stefan. And so one should operate with the Bundle directly.
If "minimal" sample will work - it will be confirmed.
Also, are you doing a GUI or a console application?
Thank you.
Also, about your comment - OSX is NOT UNIX/Linux. Those are 2 completely different OSes.
So of course they are behaving differently.
But I don;t know where/how/what OSX doing when you passing an arguments to a program. But that should be for later. Right now we are trying to fix the menu under Catalina.
Re: MenuBar in macOS Catalina
Thanks for your reply but, politely, this is covering old ground already discussed in this thread.ONEEYEMAN wrote: ↑Wed Aug 12, 2020 7:54 am Hi,
Could you try building the minimal sample and run it with:
and then check if the menu works correctly?Code: Select all
open minimal.app
Yes, (re)building and running:
Code: Select all
open minimal.app
Running:
Code: Select all
./minimal
I'm not suggesting that something has broken in wxWdgets, just that the interaction between macOS and wxWidgets (and Tcl/Tk) has recently changed.
My application is built as a macOS bundle, exactly as is 'minimal'.Please remember that Apple make it a hard requirement with Catalina to build the Application Bundle (I believe you could work without it in the past). That is according to Stefan. And so one should operate with the Bundle directly.
But building something as a bundle (all with the correct directory structure) is not the problem being discussed - somewhere along the way it appears Apple stopped sending a menu initialisation event to programs freshly invoked from the command line. It used to do this, and has recently (with Catalina) stopped. But that event sequence is now only sent when the wxWidgets application is brought back to the foreground. This also affects Tcl/Tk programs that should be able to be executed just from the command-line.
My application being discussed is a simulator, with provides awxWidgets interface if invoked with its (-W) command-line switch, or as just a text-based application otherwise. This combination works perfectly on Linux, and has on macOS before Catalina.Also, are you doing a GUI or a console application?
I'm not pointing fingers at anyone (well, maybe Apple), but do keep 'probing' to see if anyone on this forum is investigating, or has solved, this problem. Thanks for reading.
Please let's not get into semantics - macOS is as much a version of UNIX as Linux is (and there's no such thing as UNIX/Linux).Also, about your comment - OSX is NOT UNIX/Linux. Those are 2 completely different OSes.
I undertake nearly all of my software development and work on macOS while using it as a traditional Unix-like, command-line dominated box.
Re: MenuBar in macOS Catalina
Hi,
I completely agree with you.
As I said - running application outside the Bundle stops working with Catalina. And since wxWidgets tries to stay platform complaint as much as possible I believe you should bring it up with Apple, just as much as authors of Tcl/Tk.
Also, please correct me if I'm wrong, but I believe that when on OSX you invoke your program as just
it was started as background application and you had to bring it to top, as some functionality was not working. Unfortunately I don't remember exactly what but you can google this forum and check.
So, its not just with OSX and wxWidgets - its with every single GUI application on Catalina. Devs will have to build the Bundle and invoke it with "open".
Also Apple is known to break "backward compatibility" and not responding to the complaints about it.
You can try to bring it up though.
Now what's wrong with asking people to change their script to invoke:
(sorry, I don't know exact syntax here).
And finally, yes lets not go into semantics.
Thank you.
I completely agree with you.
As I said - running application outside the Bundle stops working with Catalina. And since wxWidgets tries to stay platform complaint as much as possible I believe you should bring it up with Apple, just as much as authors of Tcl/Tk.
Also, please correct me if I'm wrong, but I believe that when on OSX you invoke your program as just
Code: Select all
./minimal
So, its not just with OSX and wxWidgets - its with every single GUI application on Catalina. Devs will have to build the Bundle and invoke it with "open".
Also Apple is known to break "backward compatibility" and not responding to the complaints about it.
You can try to bring it up though.
Now what's wrong with asking people to change their script to invoke:
Code: Select all
open minimal.app -W
And finally, yes lets not go into semantics.
Thank you.
Re: MenuBar in macOS Catalina and Big Sur
I know this is an old post but the problem persists. Surely there is some way to build an OSX app that has the menu bar show up?
I did try the suggestion above of adding a new target in XCode but have not been able to associate everything with the new target properly so it will build. The older target builds just fine in XCode but then the menu does not show up.
Recompiled wx with the latest version, running latest XCode. Everything compiles just fine and the program runs just fine but the menu bar is empty.
Not sure if I should create an entirely new XCode project or if there is some easier way to actually make this work. A bit tougher since Apple has no easy way to create an app bundle in XCode that is C++ based anymore.
I did try the suggestion above of adding a new target in XCode but have not been able to associate everything with the new target properly so it will build. The older target builds just fine in XCode but then the menu does not show up.
Recompiled wx with the latest version, running latest XCode. Everything compiles just fine and the program runs just fine but the menu bar is empty.
Not sure if I should create an entirely new XCode project or if there is some easier way to actually make this work. A bit tougher since Apple has no easy way to create an app bundle in XCode that is C++ based anymore.
BeerSmith.com
Re: MenuBar in macOS Catalina
Quick update - created a new target in the same project (per one suggestion in thread above) and got it to compile - still no menu bar.
BeerSmith.com
Re: MenuBar in macOS Catalina
Hi,
Are you running application bundle?
Can you compile and run the "minimal" sample provided by wxWidgets?
How did you compile the library? How do you create Xcode project?
Thank you.
Are you running application bundle?
Can you compile and run the "minimal" sample provided by wxWidgets?
How did you compile the library? How do you create Xcode project?
Thank you.
Re: MenuBar in macOS Catalina
OK,
After trying several different things I found a solution today:
Needed to add OSX specific code to call wxMenuBar::MacSetCommonMenuBar(bar) to the frame initialization.
Older versions worked just fine when I set the menu bar as part of the wxFrame creation, but apparently under the last three builds of wxWidgets you now need to explicitly set the common menu bar using this special call when using wxFrame as a basis for the app.
After trying several different things I found a solution today:
Needed to add OSX specific code to call wxMenuBar::MacSetCommonMenuBar(bar) to the frame initialization.
Older versions worked just fine when I set the menu bar as part of the wxFrame creation, but apparently under the last three builds of wxWidgets you now need to explicitly set the common menu bar using this special call when using wxFrame as a basis for the app.
BeerSmith.com
Re: MenuBar in macOS Catalina
Hi,
Is "minimal" sample works for you?
Thank you.
Is "minimal" sample works for you?
Thank you.
Re: MenuBar in macOS Catalina
Hello All,
Further to this, I can happily report that the problem with the MenuBar on OSX has been fixed!
My environment: wxWidgets-3.1.5, macOS 10.15.7, clang 11.0.3
Thanks very much to anyone here reading this who helped in fixing the problem.
Chris.