Minimalist cocoa app, how to create a menu bar? - cocoa

I’m just trying to create a window in cocoa. I wanted to use this code as a basis but somehow the app menu does not show up (still shows the one from the terminal, un-clickable though).
Can anybody give me a hint what might have changed in cocoa since that article was written? I’m using Yosemite.

It works fine for me, but I had to Cmd-Tab switch away and back again to the running executable before the app menu became active. I tried appending a space and the ampersand symbol to the end of the code, which tells the shell to background the task, thinking it may launch normally then, but to no avail.
You might try appending an AppleScript command such as tell application MinimalistCocoaApp to activate after the command to launch ./MinimalistCocoaApp (separated by a semicolon). I'm not sure the "compile and run" terminal command for AppleScript, but that should be easily Googled.

Related

How does one disable the file menu animation in MacOS when selecting a command?

When you open the file menu (or any other menu in the menu bar), it looks something like the attached image.
MacOS file menu
In Windows, when you select the command you want, the menu instantly disappears and the action is instantly performed. In MacOS, however, the command you chose blinks, the window fades out, and then the action is performed.
I know there are commands and settings to disable certain animations in MacOS, but I can't seem to find one relating to this yet.
This is one of my major pet peeves with MacOS and I'd appreciate any help. It might be the case that I'm making a huge deal out of this when it's not as such, but it does get annoying sometimes and slows down my workflow.
Thanks!

Is there a way to determine if a terminal is focused without asking the window manager?

I want to change some tmux styling when the terminal loses focus/becomes inactive (i.e. when I've clicked on an open Google Chrome window). I know I could check with the window manager to see which application window is focused, but this doesn't work across window managers.
Do terminal emulators themselves expose this information at all?
I tried running showkey -a to see if any escape sequence was sent when focus was lost, and it doesn't look like it.
I think some terminals implement this, but not all, based on this comment on the issue tracker for the vim-tmux-focus-events plugin:
About the question "I was expecting the event to fire when changing focus between different windows in my window manager": yea, I see how that would be very useful. I think this might be dependent on the terminal application you're using. I just tested this on OSX and here's some quick results:
it's working for iTerm when tmux is running inside the window
not working for iTerm running plain bash + vim inside (no tmux)
not working for Terminal.app (with or without tmux)
[...]
So, if I'm not wrong, it's up to terminal applications to implement "focus gained", "focus lost" functionality.
I have a vague memory (though I don't remember for sure) that focus gain/loss might have worked for me when using that plugin and gnome-terminal, so it might be worth a try.

Keyboard events don't work with irrlicht on Xcode

When I run my Irrlicht application in Xcode, I can't use keyboard input:
If I press a key while the application is running, I end up writing that letter on whichever window was opened before the application, for example: I'm editing my code, than I press Build/run, the application opens (I press with the mouse on the window just to make sure it is focused) and than I press a key and that letter is written in the editor window...
I am certain the problem is not from the code, because if I press the top bar of the application's window, press the key, and release the mouse button (in a fast motion) the event gets fired..
Now, from what I read in this link (fourth post), it seems there's an incompatibility between command-line application with Xcode and irrlicht. The guy changed to a Cocoa application and got it to work. I don't know how to do this, since Irrlicht uses lots of namespaces and with cocoa I get loads of problems with it..
Any idea? thanks!
Well after a random search i found this guide:
http://irrlicht.sourceforge.net/forum/viewtopic.php?f=5&t=13890&start=60
Some things were different with my Xcode 3.2.6 (e.g. i had no *AppDelegate.m, *AppDelegate.h nor *.xib file) but easy to get to the end of the tutorial.
In the end i got like 1000 errors, something to do with precompile appkit.h errors, and with a quick search here is the solution for all those errors:
http://www.cocoabuilder.com/archive/cocoa/194905-xcode-cocoa-project-with.html#195211
easy peasy :)

OSX bash - window focusing on launched executables/apps?

If i launch a executable/another app from a bash script, this executable/app starts up normally, but with it's application window not in focus.
If you launch the script from a window for example, the bash script calls upon the other executable/app, but you can't see the app's interface because it gets launched below all windows.
For Linux there exist some window managers that can do this, like these tips here:
Is there something for OSX as well?
I realize i can set the active window via AppleScript (osascript via bash), but i wanted to do this without AS.
("tell application \"newapp\" to
activate")
My appswitch tool does exactly this.

Remembering terminal states in OS X (like Fluid for the shell...)

I have a few different things open in the terminal whenever I'm developing -- log tailing, Ruby console, plain shell in a certain directory, and so on.
How do I:
start all those things at once, hopefully in the right position on the screen?
make them distinct so I can switch to them with Quicksilver / Alt-Tab?
Fluid solved this problem with all of my web apps, so now I want to do it with my terminals.
And while we're on the topic, has anyone found a working solution for getting OS X to remember window positions on an external monitor? If I unplug it and plug it back in, I have to drag everything back to the same position (although at least Mercury Mover makes it possible to do it with the keyboard.)
Open Terminal, and go into Preferences, then go into the settings tab, and create a new setting for each of your windows that you want. Either give them all different colour schemes, or duplicate a colour scheme multiple times for them all to have the same settings. Under the shell sub-tab, add "Run command" to be run at shell startup. (This is the command that will cd to the directory you want, or tail a log).
Then initialise the windows as you want. Then click Window in the main menu and select Save Windows as Group...
In OSX Yosemite you can use (in Terminal) Window -> Save group. It will do all the work for you.

Resources