Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7710911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:14:30+00:00 2026-06-01T01:14:30+00:00

Lets go from the start Created New Xcode project,opened interface builder dragged one NSButton

  • 0

Lets go from the start

Created New Xcode project,opened interface builder dragged one NSButton and one NSTextField over the NSWindow.

Created…..,OK this is my following Code

#import <Cocoa/Cocoa.h>

@interface SampleTextFieldButtonAppDelegate : NSObject <NSApplicationDelegate> {
    NSWindow *window;
    IBOutlet NSTextField *textField;
}

@property (assign) IBOutlet NSWindow *window;

- (IBAction)button:(NSButton *)myBtn;

@end


#import "SampleTextFieldButtonAppDelegate.h"

@implementation SampleTextFieldButtonAppDelegate

@synthesize window;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    // Insert code here to initialize your application 
}

- (void)controlTextDidEndEditing:(NSNotification *)obj
{
    NSString *textFieldString = [textField stringValue];
    NSLog(@"controlTextDidEndEditing %@",textFieldString);
}

- (IBAction)button:(NSButton *)myBtn
{
    NSLog(@"button");
}

@end

Went to interface Builder,
connected textField outlet to NSTextField control,and connected delegate outlet of my textField to my SampleTextFieldButtonAppDelegate object
connected button action to NSButton control.

Assigned button key Equiv. to Return/Enter Key

Ran the XCode,initially textfield is focussed,pressed tab key from the keyboard,focus has changed to button,pressed tab key again focus went to textField.This time I typed some text in my text field and pressed Return Key.

See the following Log message I got,

2012-03-31 15:37:37.723 SampleTextFieldButton[1845:a0f] controlTextDidEndEditing
2012-03-31 15:37:41.601 SampleTextFieldButton[1845:a0f] controlTextDidEndEditing dasdj
2012-03-31 15:37:41.629 SampleTextFieldButton[1845:a0f] button

Why the button action is getting called while I am interacting with my NSTextField?Please give me some solution for this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:14:32+00:00Added an answer on June 1, 2026 at 1:14 am

    Assigned button key Equiv. to Return/Enter Key

    Ran the XCode,initially textfield is focussed,pressed tab key from the keyboard,focus has changed to button,pressed tab key again focus went to textField.This time I typed some text in my text field and pressed Return Key.

    Why the button action is getting called while I am interacting with my NSTextField?

    Because you’re pressing the enter key of your keyboard. That’s why keypress equiv are often combined with modifiers (cmd, alt, shift)

    imagine if instead of printing shortcut “cmd+p”, the shortcut was just “p”. My computer would have launched printing 5 times writing these two lines 🙂

    You can make direct key bindings, like when you build a game for example, where “z” is used to go further and “q” turn left, etc. but be sure that’s not used during text writing for example. Just disable the key binding on your button on the textDidBeginEditing event and put back the binding on textDidEndEditing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm tring to start a new activity from the main one but i'm getting
I have created a Userform that lets the user pick a worksheet from a
First off my background: I'm new to Java coming over from Ruby. If that
I'm about to start a new web project and I'm a bit stuck on
I have a set of ids in a table (column id), lets say from
So far i have an assembly script that lets you boot from it and
Lets say that input from the user is a decimal number, ex. 5. 2155
Lets say we have a derivided class SerializableLabel from the base class System.Windows.Controls. [XmlRoot(SerializableLabel)]
Lets suppose that I have the following simple query var q = from p
Lets assume i have a query like the following $query_search = SELECT * FROM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.