Page 1 of 1

[OSX 10.10] Keyboard problem with executables

Posted: Mon Jun 08, 2015 10:51 pm
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... :?:

Re: [OSX 10.10] Keyboard problem with executables

Posted: Fri Jun 12, 2015 11:40 pm
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.

Re: [OSX 10.10] Keyboard problem with executables

Posted: Sat Jun 13, 2015 10:00 am
by Wolfram
Are you sure that your program is in focus and not the terminal?
Try CMD + Tab to switch to you program.

Re: [OSX 10.10] Keyboard problem with executables

Posted: Sun Jun 14, 2015 12:19 am
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.