• 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: No Alert, Discard Change, & Beep
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: No Alert, Discard Change, & Beep


  • Subject: Re: No Alert, Discard Change, & Beep
  • From: Richard Charles <email@hidden>
  • Date: Tue, 19 Apr 2016 23:25:21 -0600

> On Apr 19, 2016, at 5:28 PM, Quincey Morris <email@hidden> wrote:
>
> On Apr 19, 2016, at 16:11 , Richard Charles <email@hidden> wrote:
>>
>> I have a NSTextField with a NSFormatter. When the user enters an incorrect value an alert sheet drops down from the document window stating “Please provide a valid value.”.
>
> Is the text field bound to a NSObjectController, or how does it get/set its value from/to the data model?

Yes, the text field is bound to an NSArrayController.

> My memory is vague on this, but I think that obnoxious sheet comes from the NSObjectController rather than the NSFormatter.

I am not sure where the alert sheet comes from but I discovered it uses the responder chain. After much trial and error the following NSResponder override seems to work well in my NSTextField subclass.

- (void)presentError:(NSError *)error modalForWindow:(NSWindow *)window delegate:(id)delegate didPresentSelector:(SEL)didPresentSelector contextInfo:(void *)contextInfo
{
    NSBeep();
    [self abortEditing];
    [self.window makeFirstResponder:self];
}

The default implementation of this method presents an error alert to the user as a document-modal sheet attached to the document window. Instead we simply beep, abort editing, and reset the text field for editing again.

The documentation cautions against overriding this method but I could not find anything else that worked.

--Richard Charles


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: No Alert, Discard Change, & Beep
      • From: Quincey Morris <email@hidden>
References: 
 >No Alert, Discard Change, & Beep (From: Richard Charles <email@hidden>)
 >Re: No Alert, Discard Change, & Beep (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: No Alert, Discard Change, & Beep
  • Next by Date: Re: No Alert, Discard Change, & Beep
  • Previous by thread: Re: No Alert, Discard Change, & Beep
  • Next by thread: Re: No Alert, Discard Change, & Beep
  • Index(es):
    • Date
    • Thread