• 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
Re: -stringValue on NSTextfield does not reflect actual contents [SOLVED]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -stringValue on NSTextfield does not reflect actual contents [SOLVED]


  • Subject: Re: -stringValue on NSTextfield does not reflect actual contents [SOLVED]
  • From: Matt Neuburg <email@hidden>
  • Date: Mon, 24 Jul 2006 10:05:42 -0700
  • Thread-topic: -stringValue on NSTextfield does not reflect actual contents [SOLVED]

On Sun, 23 Jul 2006 10:19:58 +0200, Philip Dow <email@hidden> said:
>A suggestion was made off list that I add a [title validateEditing]
>before requesting the text field's contents. This did the trick. As
>the docs say:
>
>- (void)validateEditing
>Validation sets the object value of the cell to the current contents
>of the cell's editor (the NSText object used for editing), storing it
>as a simple NSString or an attributed string object based on the
>attributes of the editor.
>
>For anyone else that comes across this problem, you must call this
>method before closing the window, as the field editor belongs to the
>window. I stuck it after the modal code but before ending the sheet:
>
> [NSApp beginSheet:sheetWin modalForWindow:[self window]
>modalDelegate: nil didEndSelector: nil contextInfo: nil];
> result = [NSApp runModalForWindow:sheetWin];
>
> [title validateEditing];
>
> [NSApp endSheet:sheetWin];
> [sheetWin close];

But this assumes that you know what control is being edited. It is much more
usual to say:

[sheetWin makeFirstResponder: nil]; // end any editing

Even this will not guarantee that editing will end, since the editee might
fail validation; RTFM for code that deals with that situation.

Also, on a different topic, I realize this conversation has been held
before, but I find it very odd behaviour to begin a sheet with beingSheet:
(which makes it window-modal, automatically) and then suddenly call
runModelForWindow: on the sheet (which makes it app-modal). If you wanted an
app-modal window, why did you summon a sheet? The standard UI is that
stand-alone dialogs are app-modal, sheets are window-modal. m.

--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



 _______________________________________________
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: -stringValue on NSTextfield does not reflect actual contents [SOLVED]
      • From: Philip Dow <email@hidden>
  • Prev by Date: DO Message queueing issues
  • Next by Date: Can switch be used here?
  • Previous by thread: Re: DO Message queueing issues
  • Next by thread: Re: -stringValue on NSTextfield does not reflect actual contents [SOLVED]
  • Index(es):
    • Date
    • Thread