[OSX 10.10] Keyboard problem with executables

Mac OSX specific forum
User avatar
kenmo
Addict
Addict
Posts: 2081
Joined: Tue Dec 23, 2003 3:54 am

[OSX 10.10] Keyboard problem with executables

Post by kenmo »

Hello Mac experts...

PB lets us build Mac executables without a .app bundle (see the Help):
When creating an executable on OS X, appending '.app' at the executable name will create a bundled executable with the necessary directory structure, including the icon. If no '.app' is set, then it will create a regular console-like executable.
I like to use this feature for commandline console programs. But with PB 5.31 / OS X Yosemite, if I call Requester functions from this type of executable, I can't type anything into them! (The keyboard input seems to go to the terminal instead.)


Try building this as a non-app executable (might need to create a Project and Build Target)

Code: Select all

SaveFileRequester("Title", GetCurrentDirectory(), "All Files|*.*", 0)
Then run it from Terminal or Finder and try to type into the SaveFileRequester.

Is this a bug? Is there a workaround? Or is this expected behavior on OS X? Maybe I'm forced to build a complete .app for any commandline program which might open a Requester?


EDIT: I tried compiling to a .app and copying the executable out of the .app Contents, but it didn't make a difference (executable seems to be identical whether in an app or not). For some reason, running via .app gets keyboard input (even launched from a Terminal) but running an executable directly sends keyboard input to the console... :?:
User avatar
kenmo
Addict
Addict
Posts: 2081
Joined: Tue Dec 23, 2003 3:54 am

Re: [OSX 10.10] Keyboard problem with executables

Post by kenmo »

Very strange... (still on OS X 10.10)

. If I build a standalone executable, Requesters don't receive keyboard input (typing goes to the background terminal).
. If I build a complete .app from PB, it works, and I can type into Requesters.
. If I copy the .app's executable into another folder, keyboard input does not work.
. If I also copy the .app's Info.plist into that same folder (next to executable), keyboard input works again.


I found this open source tool for embedding PLIST files inside a standalone binary:
https://reverse.put.as/2013/05/28/gimme ... -binaries/
It seems to work (injects the Info.plist generated by PureBasic into the binary executable), but when tested this seems to have no effect on the keyboard input problem!

OS X is strange. :shock: Any ideas? I'm trying a lot of things, just to have an optional Requester-mode in a commandline tool.
Wolfram
Enthusiast
Enthusiast
Posts: 610
Joined: Thu May 30, 2013 4:39 pm

Re: [OSX 10.10] Keyboard problem with executables

Post by Wolfram »

Are you sure that your program is in focus and not the terminal?
Try CMD + Tab to switch to you program.
macOS Catalina 10.15.7
User avatar
kenmo
Addict
Addict
Posts: 2081
Joined: Tue Dec 23, 2003 3:54 am

Re: [OSX 10.10] Keyboard problem with executables

Post by kenmo »

Yes I am sure the Requester has focus - at least mouse focus. I can click and interact with the Requesters, and textboxes show a blue outline when I click in them. I can even right-click and paste text, but keys don't work.

I found some other OS X users with "keyboard input goes to the terminal" issues, but haven't found a clear solution. Here are 2 quick links:

http://stackoverflow.com/questions/2718 ... -of-python
https://github.com/coolwanglu/neovim-e/issues/7

I also noticed (since the 2nd link mentioned it) that the Cmd+Tab popup does show the Requester when Info.plist is present, but does NOT show it when running a standalone executable.
Post Reply