• 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: copy in WebView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: copy in WebView


  • Subject: Re: copy in WebView
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Sun, 14 Oct 2012 15:17:32 +0700

On 14 Oct 2012, at 03:26, Kyle Sluder <email@hidden> wrote:

> On Sat, Oct 13, 2012, at 01:19 PM, Andy Lee wrote:
>> Unless I'm mistaken, Kyle meant the view hierarchy, not the inheritance
>> hierarchy. In other words, if you go up the superview chain starting at
>> the window's first responder, do you encounter your WebView?
>
> You are correct. I was referring to the view hierarchy.
>
> And I just realized that Gerriet is on the Mac, not on iOS, so he
> doesn't need to traverse the view hierarchy to determine who first
> responder is after all. He can just ask the window, as you suggest. Then
> he can ask if that object is an instance of NSView, and if so send it
> -isDescendantOf: to determine if it is a descendant of the WebView.
>
> No private API required.

Thanks for all your suggestions!

Now I have (in my app delegate, which handles the Edit → Copy menu item):

- (id)targetToHandleCopy
{
	NSApplication *sharedApplication = [ NSApplication sharedApplication ];
	id target = [ sharedApplication targetForAction: @selector(copy:) ];
	if ( target == nil ) return nil;
	if ( ![ target isKindOfClass: [ NSView class ] ] ) return target;
	NSView *aView = (NSView *)target;
	for(;;)
	{
		if ( [ aView isKindOfClass: [ WebView class ] ] )
		{
			NSDocumentController *sharedDocumentController = [ NSDocumentController sharedDocumentController ];
			NSWindow *window = [ aView window ];
			MyDocument *m = [ sharedDocumentController documentForWindow: window ];
			if ( [ m isKindOfClass: [ MyDocument class ] ] ) return m;
		};

		aView = [ aView superview ];
		if ( aView == nil ) return target;
	};
}

//	Edit → Copy
- (IBAction)cleanCopy: sender;
{
	id targetToHandleCopy = [ self targetToHandleCopy ];

	if ( [ targetToHandleCopy isKindOfClass: [ MyDocument class ] ] )
	{
		[ targetToHandleCopy cleanCopy ];
	}
	else
	{
		[ targetToHandleCopy copy: sender ];
	};
}

No more undocumented methods used.

Gerriet.


_______________________________________________

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


References: 
 >copy in WebView (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: copy in WebView (From: Kyle Sluder <email@hidden>)
 >Re: copy in WebView (From: Kyle Sluder <email@hidden>)
 >Re: copy in WebView (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: copy in WebView (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: copy in WebView (From: Kyle Sluder <email@hidden>)
 >Re: copy in WebView (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: copy in WebView (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: copy in WebView (From: Kyle Sluder <email@hidden>)
 >Re: copy in WebView (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: copy in WebView (From: Andy Lee <email@hidden>)
 >Re: copy in WebView (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: IBOutlet & NSNumber
  • Next by Date: Re: copy in WebView
  • Previous by thread: Re: copy in WebView
  • Next by thread: Re: copy in WebView
  • Index(es):
    • Date
    • Thread