wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
23.49k stars 1.12k forks source link

macOS input stays in terminal and not the wails window. #3163

Open precisionpete opened 6 months ago

precisionpete commented 6 months ago

Description

Can someone please explain how this is supposed to work? I am building a multi-platform app with go 1.21, wails 2.7.1, sveltekit.

Under Linux, it works great.

It seems for macOS, I am unable to get keyboard input into the Wails window. Even when selecting an input field, and seeing the field selected, typing still shows up in the terminal windows that launched the Wails app. I also do not see the icon in the tray icon at the bottom.

This is only when the app is built with wails build. If I start it with wails dev, it works as expected.

Also, when I specify -o filename, it ignores that setting and always creates it in ./build/bin/Package.app/MacOS/Package

If I run it from that location, it works. If I move and rename the file to another folder, it runs without input.

This app is meant to be distributed in a pkg and be installed in /usr/local/bin on the Macs.

There is enough odd stuff that I expect this is normal. But I can't seem to find any documentation to explain what's expected.

Plus, I swear I had it working normally in the past.

To Reproduce

See above

Expected behaviour

If a text field has focus, typing should show in that field.

Screenshots

No response

Attempted Fixes

No response

System Details

MacOS Monterey and Sonoma running in a VMware Workstation 17 VM. Host is Linux Mint 21 (22.04)  amd64.

Additional context

No response

yaoyaochil commented 6 months ago

me too

precisionpete commented 6 months ago

I'm getting a gazillion of these in the system log... A clue. I'm opening the window as a child of the systray icon in the menu bar... Works fine though on windows and linux.

2024-01-13 16:25:14.261403-0500 0x468c Error 0x0 1555 0 myapp-ui: (AppKit) [com.apple.AppKit:General] nextEventMatchingMask should only be called from the Main Thread! 2024-01-13 16:25:14.261859-0500 0x468c Error 0x0 1555 0 myapp-ui: (AppKit) [com.apple.AppKit:General] ( 0 CoreFoundation 0x00007ff805d47d86 __exceptionPreprocess + 242 1 libobjc.A.dylib 0x00007ff80583a321 objc_exception_throw + 48 2 AppKit 0x00007ff809bdaadd -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:i^C 0x00007ff809bdaadd -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 4241 3 AppKit 0x00007ff8092d2d32 -[NSApplication run] + 603 4 myapp-ui 0x00000001003268be nativeLoop + 62 5 myapp-ui 0x0000000100325262 _cgo_423650e18c01_Cfunc_nativeLoop + 34 6 myapp-ui 0x000000010006d088 runtime.asmcgocall.abi0 + 104 )

leaanthony commented 6 months ago

We don't support systray in v2 - native support is coming in v3. Some developers have had success in integrating with systray libraries but are hacks due to the fact that both will want to own the main thread. I would fully expect these kinds of issues. It looks like there's an attempt to do some UI operation off the main thread.

precisionpete commented 6 months ago

Getting somewhere... If I launch my app from the wails-generated MyApp.app application bundle, it works as expected... I was trying to extract the binary and copy it to /usr/local/bin. That's where the text input problem starts. Even the systray stuff works if I launch the Bundle.app.

You can tell by now that I am NOT a Mac developer by trade... More a Linux and Web background. Wails is fantastic! But I still have a way to go on the cross-platform stuff.

What I am trying to accomplish is:

Linux and Windows are working great and macOS is very close. I'm just struggling with launching and the text input thing. BTW, it works fine with 'wails dev'. I'm sure macOS is squashing me because I said something nasty about them once.

As long as I'm asking for the sky here... I would love to get it all running from the app bundle rather than my current installer.pkg file. Ideally, installing the app bundle will create the LaunchDaemon and LaunchAgent and I don't need to mess around with /usr/local/bin etc at all.

I know Wails it not the problem here. I'm pretty sure it's an apple thing. If this approach makes sense or not, I would love to hear learned opinions...

Thanks for listening.