Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to intercept call to [NSTextView print:] of NSSearchfield in a toolbar



the "environment"

my MyWindow (a subclass of NSWindow) has an NSToolbar that contains an NSToolbarItem with an NSSearchfield as its view.

in my main nib, the Print menu item has its action set to print: in the first responder.

MyWindow has a print: method that prints the contained tableview with appropriate headers/footers and pagination.

the "problem"

if the user is entering text into the search field (or if s/he has simply tabbed into the search field) and then selects the Print menu item (or types Command-P), then the NSTextView which is the field editor for the search field gets sent the print method and proceeds to print the search field contents. what i want (and what i believe users will expect) is for print to print the table view, not the search field.

my "solution"

in MyWindow, i have overridden fieldEditor:forObject: to return MyTextView (a subclass of NSTextView) and sets it up as a field editor. MyTextView has only one method, print:, which simply calls [[self window] print: sender].

my "question"

is this the only/best way to solve my "problem"? it seems a little clumsy to me. ie, is there some other way that i could simply intercept the print message sent to the field editor?

thanx,
ken

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.