Closing frontmost window in Cocoa in an app without a menu bar - objective-c

I am building a StatusBar App in Cocoa, therefore I have no menu. Having no menu implies not having a "File > Close" menu item, which normally listens to the shortcut "Command + W".
From my StatusBar App the user may open a window to change the preferences and that's where I'm running into problems: The user can only close the window by pressing the red dot with the mouse. However, like alle applications I want to support the "Command + W" shortcut as well.
At the moment I see two possibilities to solve this issue:
Place an invisible button on the window which listens to the shortcut.
Add an application-wide listener for the shortcut and contact the window manually.
Both solutions feel like a misuse of the system. The first solution can lead to unexpected behaviour (the window closes if the user hits the invisible button by chance) and the second solution will still result in a beep, since the window does not know that it handles such a shortcut.
Is there an elegant way to solve this problem? Since the view should know what to do, a solution with just Interface Builder would be perfect. If there is no elegant way, is there a way to enhance the solutions mentioned?
Thanks in advance!

If you put a File > Close menu item in your MainMenu nib, the shortcut will work, even though the menu isn't visible.
If you choose to implement an app-wide listener for the shortcut instead, you can get rid of the beep by returning nil from the block, so that the original event doesn't get passed on.

Related

Disable certain suggestions in PhpStorm search

I’m not sure what are these called:
I mean the Show code with my wire stats, Show Memory indicator, etc..
Basically, I’m mostly interested so this autocomplete menu would only show files, or at the very least would prioritise files. How can this be achieved?
I’m in version 2022.2.1.
That popup is called Search Everywhere and you are on an "All" tab that includes combined results from Classes, Files, Symbols, Actions etc.
Either manually switch to the desired tab (using a mouse or by hitting Tab needed number of times) or invoke this popup for the desired search from the start. For that just use the shortcut for Navigate | File... (Ctrl + Shift + N here on Windows keymap).
https://www.jetbrains.com/help/idea/searching-everywhere.html
Found the solution.
These things are called Actions, and the can be disabled in menu that appears after clicking the small funnel icon in the top right:
I tested, these changes seem to 'survive' a restart.
Yes, at the moment it is remembered only during the session.
https://youtrack.jetbrains.com/issue/IDEA-229285 -- watch this ticket (star/vote/comment) to get notified about any progress.
(P.S. The same happens with Find in Files popup (IDEA-143972) and a few others similar popups as well)

How can I move focus from the Quick Documentation pop-up back to the Code completion pop-up without using the mouse?

Context:
When a code completion pop-up (Ctrl+Space) appears I often need to have a look at docs for each individual method / constant / etc). The IDE is set to show the Quick Documentation pop-up for a highlighted suggestion automatically after a small delay. Sometimes the documentation is too big and I need to jump to the Quick Documentation pop-up in order to be able to scroll down through it.
Using the mouse I can click on the documentation pop-up and scroll using the mouse wheel. When I'm done reading the documents I can click on the code completion pop-up to explore other suggestions.
My problem is that once the Quick Documentation pop-up is in focus, I haven't found a way to move the focus back to the code completion pop-up without using the mouse.
While I can move focus from the code completion to the quick documentation pop-up by pressing Ctrl+Q, and then use the arrow keys to "scroll" through the documentation, I haven't found a shortcut to return the focus to the code completion pop-up.
What I've tried to far:
Esc closes both pop-ups
Pressing Ctrl+Q a second time opens the docs on a tool window
Any insights on how I can close the Quick Documentation pop-up or move the focus back to the code completion pop-up in such a way that preserves the suggestion that I have previously highlighted?
This seems to be a bug in IntelliJ IDEA . Feel free to add your use-case at https://youtrack.jetbrains.com/issue/IDEA-168388
Here is a workaround that could be used for the time being:
Open Documentation as a Tool Window:
Add keyboard shortcut to focus documentation window from anywhere:
When the completion popup appears, focus documentation tool window by the shortcut from [2] and scroll it
Press Esc to unfocus documentation tool window and focus completion popup

IntelliJ IDEA secondary windows lack a menu. How can i enable it?

I'm a frontend developer and I have a multi-monitor setup. I have HTML code on one monitor and CSS code on another monitor.
To achieve that, I drag a tab out of IntelliJ IDEA window, so that the tab opens in a separate window.
My problem is that the secondary window lacks a menu:
Menu access hot keys (e.g. Alt+V) won't work. I can't make use of the main window's menu either because when I click it, the focus switches to the active tab of the main window.
How do I access the menu when I'm working in IDEA's secondary window?
This feature is currently not available in IntelliJ IDEA.
The alternatives I could think of to do what you want:
Consider raising a feature request on http://youtrack.jetbrains.com/
Do you think it's possible that you might not miss the menu on the detached tab if instead of accessing functionality through the menu, you did the same through keyboard shortcuts?
Personally, being a keyboard junkie, I have not felt the lack of a menu on the detached tab.
Even though Eclipse allows you to create a new window for the same workspace, I had some issues with it ( for eg: if you set a breakpoint in a file in Window 1, and started a debug session from Window 2, then the file would be re-opened in Window 2 when the breakpoint is hit) and feel that the Intellij IDEA implementation works better.
(Warning! The most Hacky suggestion) Assuming you are using Windows, there are a number of ways in which you could extend the single IntelliJ window across the two monitors and then instead of detaching a tab, you could do a 'Split Vertically' in that single window. With the slider between the tabs positioned just right, it will seem you have two windows opened with each of them having a menu.
To extend a window across two monitors see : How can you maximize a window on to dual monitors in Windows 7 or use one of the multi-monitor tools listed here or here ( I vaguely recall that it was the latter 'zbar' that I used to extend a window during my eclipse days).
Believe it or not, I have done this with Eclipse when I was sick of guessing where the file-with-the-breakpoint would open up :)

Check if software keyboard is open in Windows Phone 8?

I want to check if the software keyboard is open in Windows Phone 8. I have found some sparse information that this is possible using CoreWindow.IsKeyboardInputEnabled, but I can't find any way to implement this. I have found sample code only for C++, which I don't understand at all.
I use VB, however I can read C# enough to figure it out if I can get a C# example.
Whatever I do I always get a null/nothing value. The following code compiles and runs, but c is 'nothing' when the app crashes at the if c.IsKeyboarInputEnabled... line.
Dim c as CoreWindow
c = CoreWindow.GetForCurrentThread
if c.IsKeyboardInputEnabled then...
I know I need to give 'c' a value, but can't figure out how. I've also tried:
Dim c as CoreWindow = New CoreWindow
which the editor flags as an error and thus won't compile.
If it's relevant, what I am trying to do is ensure my navigation is consistent. Currently, a tap on a particular screen element should close that element. However, if the keyboard is open, I want that tap to simply close the keyboard and leave the tapped item open. I believe this is the more intuitive and consistent approach for the user.
I think the only way to achieve this functionality is to know if the keyboard is open before determining what to do with any open panels.
e.g.
[when screen tapped and a popup is expanded]
If [keyboard visible] then [close keyboard] else [close tapped item]
I don't think there is any official API to detect the opening and closing of the SIP but one workaround might be to check if any of your TextBoxes have focus.
You can do this by overriding GetFocus and LostFocus for each TextBox.
To close keyboard, just set the focus to the ContentPanel(or any other grid).
Let me know if this works.

Is there a keyboard shortcut to maximize/minimize the output window in Xcode 4?

I'm currently trying to workaround some apparent shortcomings of cocoa touch application tests in Xcode 4 (see this related question). Since failures of application tests are not highlighted in the editor window like failures of logic tests, I find myself using the mouse to scroll through the output window to see the results of failed tests.
I would prefer to use keyboard commands if possible to quickly look at the results of the tests and then quickly move back to the editor. Are there some keyboard shortcuts in Xcode 4 for maximizing and minimizing the output window?
It looks like Command+Shift+Y opens and closes the debug area, but I don't know of a keyboard shortcut to maximize it.
Here's a nice cheat sheet you can print out with lots of keyboard shortcuts.
I haven't found a direct shortcut, but along with Jose Ibanez shortcut, here are some relevant ones.
Cmd+0 Toggle left pane
Cmd+Alt+0 Toggle right pane
Cmd+Shift+Y Toggle bottom pane