Create a cocoa button that accepts keyboard input - cocoa

Hey everyone, thanks for all your help so far, I've learned a whole lot in a short amount of time.
What I've done so far is to create a small calculator program and it works nicely. To complete this version of it, what I'd like to do is make my "keys" on the calculator interface accept input from my keyboard presses. So, for example, if I want to add 2 and 4, instead of clicking my "2" and "4" buttons, I can just press them on my numeric keypad instead.
I know it has something to do with giving my buttons focus but I can't figure out how to make them respond to keydown events.
I'm looking around on the apple developer documentation as well, so if I find the answers before you guys can then I'll try what I find out, and if it doesn't work I'll post with my progress.
Again, thanks everyone for your help!

You can set the key equivalent in interface builder. Click on the button in interface builder open the inspector and open it to the first tab. Under the first section there is a Key Equiv: and a gray box you can click on. Click on it and press the key you want to press it.

If you're using interface builder, just set the "Key Equivalent" field to be your number.

Related

Is there a key in the keyboard that is the opposite of an escape key?

When you press the escape key, for example, in a YouTube video, it comes out. I recently saw someone press a button to put it in a video and not the other way around as opposed to esacpe, in the keyboard
If you mean putting the video full screen you just need to press the 'f' key. But there is no generic key that allows you to do something like this, it depends on the application.

Is it possible to Customize the Text input Scope of Textbox?

in my application I used a Textbox with input scope "text". When I type in Textbox, I can see a suggestion bar above the keyboard which contains some words.If I type a in Textbox I can see the words "and","are","at"...etc.I want to customize these words.
for example if I type "a" I want to show the names "alan","alex"..etc.
Is there any way to change this?
Please help me
Is there anyway to customize the words appearing in the auto complete suggestion bar for text input scope in
You also can't do anything AT ALL with the keyboard. If this is for a custom app, perhaps a list would work such as the list in the people hub for example. Pretty sure MS isn't releasing any keyboard API's for WP8 either, so the only alternative is a workaround or alternate method.
There is no way to control text suggestions in the auto-complete bar. You are only able to choose type of input scope and no more.

Is it possible in any browser to find text on a webpage using search and "clicking" it without the mouse?

Lets say I have a page with 1000 blue links stacked on top of one another. I want to find one that matches pattern "blah" so I press ctrl-F/cmd-F and type in "blah". I find the link, it's highlighted for me. Here's my question...
Now that the browser has highlighted this link, is there anyway I can "click" on it instead of having to grab the mouse? I basically want to move my tab focus to it so I can just press enter and move on.
Thanks in advanced.
Somehow I discovered that this feature is already implemented in Chrome: just press Ctrl+Enter. :)

Is there a hot key available or configurable in Xcode for the "back button"?

The backbutton in Xcode is super useful for me, especially when I CMD+CLICK to see a declaration, but I always have to use the mouse to click the arrow back button. Is this configurable to hot key?
Thanks!!!
^⌘← unless I redefined that :P
Press "⌘," and go to Key Bindings to see the whole list. You can type "back" in the search box.
I have a Logitech mouse with physical back/forward buttons. By default these buttons map to ⌘[ and ⌘]. Unfortunately these keystrokes default in Xcode to Shift Left (outdent) and Shift Right (indent), which are not what I expect when using my mouse.
So I just remapped ⌘[ to Go Back and ⌘] to Go Forward, though I also had to remove a few conflicting key bindings in order to do it.
Works great now, and I don't have to install any horrible Logitech software (stick to hardware, Logitech!). ;)

Can I add my own code snippets to xcode 4?

It'd be really handy to have collection KVC accessor snippets in xcode, as they're a pain to do by hand. Has anyone who's been using 4 for a while worked out how to add new ones?
(...we're allowed to talk about it now, right?)
Yes, it's quite easy - you just highlight text you want to use as a snippet and drag it into the snippets area (dragging selected text can be difficult, I find it works better if you drag from the left edge of the editor). It brings up a dialog box asking you to name it.
Also, you can have custom parameters in snippets - if you put the text <#paramName#> anywhere in the code you are dragging, when you use the snippet it will come up as a replaceable parameter that you can tab between just like in the official Snippets.
Also make sure to set a completion prefix, which makes it shorter to activate the snippet as you are typing. The nice thing about using Snippets over other solutions like global system text expanders, is that snippets can also be limited to being valid in a certain area of code - so for example a snippet that filled out a string formatting line can be marked as valid only within a block, not outside a method. That way the completion prefix only hits in areas where it's valid to use.
You can edit a snippet by clicking once on it, a box will come up with the snippet text and some other snippet settings you can edit.
A tip to help you drag the code every time, select text then click + hold (do not move mouse) until mouse pointer changes from "I" to pointer. You'll then be able to drag the selected text to the Code Snippet Library.
Drag the highlighted code to the Snippet library. (It can be stubborn and not want to drag. Holding the mouse button down for a moment before dragging seems to help.)
You can use Snippets to manage code snippets in Xcode. Check out this demo http://www.youtube.com/watch?v=il4kE4diy0k
Simply select the code, the press ALT key and drag it into the code snippets library and rename it there, Make sure to press the ALT key, other than this you won'n be able to drag it.

Resources