• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Strange NSTextField behaviour
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Strange NSTextField behaviour


  • Subject: Strange NSTextField behaviour
  • From: Peter Browne <email@hidden>
  • Date: Tue, 21 Dec 2004 22:19:49 +0000

I have an NSTextField within a window (the window is a custom NSWindow subclass if this is important) that appears as a sheet for an NSTabView called MFDtabView. When the sheet is ended by clicking a button, i want the content of the NSTextField named userNameTextField to be used as an NSString (the purpose of this is to simulate a 'login' process, where by the user enters their username which is then checked against a set of known usernames etc).

However, when the sheet is ended, the content of the NSTextField seems to be unavailable. The NSLog shows the contents of the textfield to be NULL which to me suggests a broken connection of some sort. Any ideas? Here is the relevant code:

- (id)sender // Called when the login button is pressed
{
if ([ModeID isEqualToString:@"2"]) {


[NSApp beginSheet:userNameWindow
modalForWindow:[MFDtabView window]
modalDelegate:self

didEndSelector:@selector(loginSheetDidEnd:returnCode:contextInfo:)

contextInfo:NULL];
}
}

- (id)sender // Called when the OK button in the resulting sheet window is pressed
{
// Hide the sheet
[userNameWindow orderOut:sender];


// Return to normal event handling
[NSApp endSheet:userNameWindow returnCode:1];
}

- (void)loginSheetDidEnd:(NSWindow *)sheet

returnCode:(int)returnCode

contextInfo:(void *)contextInfo;
{
NSString * username = [userNameTextField stringValue];
NSLog(@"Now logged in as %@", username);


[usernameMFDDisplay setStringValue:username]; // Display the name of the currently logged in user


[self checkUserAgainstDatabase];
}

- (void)checkUserAgainstDatabase
{
NSString * usernameCheck = [knownUsers valueForKey:@"username1"];
if ([username isEqualToString:usernameCheck]) { NSLog(@"Welcome %@", username); } else { NSBeep(); NSLog(@"Sorry, user %@ has not been recognised."); }
}

Thanks in advance,
Peter
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Strange NSTextField behaviour
      • From: Fritz Anderson <email@hidden>
  • Prev by Date: Re: Interface Builder (How to list an object instance in "Bind to" popup menu?)
  • Next by Date: I cant get my helper tool to launch
  • Previous by thread: Re: Interface Builder (How to list an object instance in "Bind to" popup menu?)
  • Next by thread: Re: Strange NSTextField behaviour
  • Index(es):
    • Date
    • Thread