How to navigate through subviews in Interface Builder - xcode

I think I remember reading once there is a way to navigate through the different views in Interface Builder using a keyboard shortcut (in other words select a subview that is underneath another subview by clicking on the view) but I can't seem to find what it is. Does anyone know?

There are commands for jumping between clipped (obscured) objects, but they don't have keyboard shortcuts assigned when Xcode is installed. You can set your own shortcuts in Xcode's Key Bindings preference panel, though:
Since you'll never be editing MacOS X and iOS views in the same file, you can go ahead and assign the same shortcut for corresponding commands in each editor, i.e. use one shortcut for both Jump to Next Object with Clipped Content commands.

Related

OS X Application Keyboard Shortcuts

I am making my first OS X application in Xcode, and I have no idea how to make a specified keyboard shortcut trigger some code (e.g. ⌘ Cmd+ C/⌘ Cmd+V). All I can find online is keyboard shortcuts in Xcode itself.
Thanks in advance
This is usually setup for you automatically. The MainMenu.xib by default has an Edit menu with these shortcuts bound, activating [firstResponder copy:] and [firstResponder paste:]. The first responder is item currently having keyboard focus, or it's parent view if it doesn't answer to those actions, up to the window at the top level.
For new shortcuts, Apple recommends that you have menu items associated to all those. If you do, you can set the shortcut in the interface builder using the attributes inspector. You then ctrl-drag from the menu item to the object you want to send the action to, e.g. the app delegate. You will have to create the target method first obviously. You should also use bindings to control when the menu item is enabled or not.
It's not recommended, but if you want to do this programmatically, without a menu item, you override the
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
method of the view or window in question. It will be called if it's in the responder chain when the key is pressed, and you return YES to indicate you've handled the event.

How to unbind Command-Control-Space key from Mac OS X 10.9?

How can I unbind Command-Control-Space from Mac OS X 10.9?
This shortcut shows Special Characters table and conflicts with my Emacs key binding, and I couldn't disable it from System Preference->Keyboard->Shortcuts.
Thanks.
At least on macOS Sierra to macOS Big Sur ⌃Space is the default binding for Select the previous input source which is on by default (even if only one input source is activated).
You can free it by:
Open System Preferences
Go to Keyboard > Shortcuts > Input Sources
Untick "Select the previous input source"
Afterwards, you should be able to bind it as expected.
You can create custom keyboard shortcuts for most app's menubar choices in System Preferences. If a desired key combination is losing precedence to a default shortcut that you don't use and can't easily disable, simply override it with a new, unobtrusive shortcut.
Open System Prefs / Keyboard / Shortcuts. Select App Shortcuts from the left pane. Toggle the All Applications category's triangle in the main window to point downward (if it's not open already).
If there's an item named Emoji & Symbols* shown there, then click its shortcut combination and enter a new shortcut (such as option-shift-command-t, in this case).
If there's not an item named Emoji & Symbols under All Applications, click the + button at the bottom, type or copy-paste Emoji & Symbols, and then enter a new keyboard shortcut (option-shift-command-t, or anything really). This will free the control-command-space combination for you to use as a specialized shortcut elsewhere.
To remove your custom shortcut, just click to highlight it in the main window of this preference pane, and click the – button at the bottom. The custom shortcut will disappear and the default action will resume.
*Note: On versions older than Mac OS 10.10.3, the menu item is called Special Characters… instead of Emoji & Symbols.
I don't know of any way to disable this, but an alternative option might be to create a shortcut for the app you want to use that in. I created a Command-Control-Space shortcut for Chrome and now Command-Control-Space doesn't bring up the special character palette anymore in Chrome.
failing that you may be better off asking in Apple Stackexchange

Xcode: More efficient keyboard-based "back" navigation

In Xcode when we hold the mouse down on the "Back" arrow in the panel above the editor area, we get a popup window showing our navigation history. This is also a standard navigation behavior, seen in most Web browsers.
My question: Is there a keyboard shortcut (or XCode plugin) to pop open this Navigation History popup, so we can use arrow keys and quickly move a selection bar down to the item in the history list we would like to navigate to?
Rationale: When working in a given class, we tend to flip back and forth quite a few times between the .m and .h files for the class. Each flip creates an entry in the navigation history. So, to move back to the prior class we were editing, using keyboard shortcuts only, we need to hit the "go back" keyboard shortcut many times, undoing each flip between header/implementation. Seeing the list visually allows us to quickly identify and scroll down to the desired class in the history list, navigating directly there. When editing code, allowing the hands to remain on the keyboard is better.
Another solution could be: A keyboard shortcut to move back to the previous class (or .xib or other "significant" navigation item) rather than the previous file.
Is there a keyboard shortcut (or XCode plugin) to pop open this Navigation History popup
Yes. The standard key binding is Ctrl2, as indicated above. You can check the key bindings panel in Xcode's preferences for the current key binding on your system if there's any chance that you might have changed it.

Mac OS keyboard shortcut to toggle two menu items

I am working on a dedicated keyboard shortcut controller for a specific app, Avid's Pro Tools. There is a default keyboard shortcut that toggles the view of two windows, "Mix" and "Edit."
Both of these commands have entries on the Window menu in the app. However, there is a little check next to the window that is active, and a little diamond next to the window that isn't. So these switch as the window is toggled (by the single keyboard shortcut).
I'm looking for a way to program a different key using the Mac OS System Application shortcuts. When I assign a new keyboard shortcut to the "Mix" and "Edit" menu items, I don't get the toggle behavior, it just causes the first item in the menu to be active. This makes sense, as it is getting two commands at once. To get the behavior I want now I have to use two keyboard shortcuts, which breaks a UI convention in Pro Tools. Any suggestions appreciated!

How can I display a hidden view in Interface Builder which is on a unattached monitor?

I am using Interface Builder to work on NIBs and one of the NIBs must have a view on my external monitor which is not attached because I cannot see it on my MacBook. I have had this problem with editing iPad NIBs which I work on with my larger external monitor.
For some reason Interface Builder is not detecting that there is now just one screen and not pulling this view onto this monitor. There has to be a way to get this back into the visible space so that I can work on it. I have tried double clicking on the view icon in the organizer which normally brings the view forward but it is not coming into view.
What can I do? Is this really a bug that has been around this whole time?
I was seeing this problem as well -- the easiest way to fix it is:
In Interface Builder, double-click on the view object. This would ordinarily bring up the window and give it focus, but in this case it's invisible.
Hit Cmd-W to "close" the invisible window
Double-click the view object again; the window should now re-open onscreen.
Yes - it messes up this way when a XIB is created on a computer with multiple monitors but then later edited on different computer with just one.
To my knowledge the only way to fix is to to open the XIB with a text, or ideally XML, editor and search for negative values in various positioning strings. I've searched for {{-and then changed any negative values found to 0. For example, you'll run across {{-237,172}} When you find the open brace, open brace, minus sign pattern then change the negative value to a zero. i.e. {{-237,172}} becomes {{0,172}}.
When you re-open the XIB in IB you'll then be able to see your views.
To be safe make a copy of the XIB before hand editing.
Try using Exposé to see if the window shows up there. Ordinarily you can use Window > Arrange in Front to rearrange your windows, but it seems the non-document windows in IB don't obey ordinary Cocoa window handling so this command has no effect on them.
I wasn't able to reproduce it myself (when I disconnected my 2nd monitor, the window on it moved to my main monitor), but it may have something to do with the arrangement of your screens. If this turns out to be an IB bug you can reproduce, please file it (bugreport.apple.com).
Not sure if this will work, but open the window from your xib (double-click it) in Interface builder, then go to the "Window Size" section of the inspector. 2 Places might help in there, first the "Initial Position" shows a representation of the window and you might be able to just drag it back to the proper place. Second is "Content Frame". There are "X and Y" settings so try changing them to 0 and see if that does it.
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>WhatEverYouNamedIT</string>
<string>UIResponder</string>
<string>{{237, 644}, {320, 480}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object
I opened the .xib file with Dashcode and changed the {{237, 644} to {{0, 172} saved and opened with IB and the view "canvas" windows was back on my laptop screen everything else opened up on my external monitor.
THANKS!!!

Resources