On Mar 19, 2014, at 12:34 PM, Leonardo <[email protected]> wrote:

> Hi, I create a WebView, load the html code and add it to an NSView. It
> works. Now I would like to do something better. I paste the html code within
> my NSTextView, then in the textView's drawRect method, when the textView is
> the first responder, I display the text, as usual. When the textView is not
> the first responder, I would like to display the content of the webView.
> I did this way, but it doesn't work.
> 
> // from my NSTextView subclass
> - (void)drawRect:(NSRect)rect
> {
>    if(mInEditing == NO){
>         [mWebView drawRect:rect];
>    }
>    else{
>         [super drawRect:rect];
>    }
> }
> 
> If I replace mWebView with a regular NSView, this code works.
> I can clearly see the content of that NSView. But it doesn't work with the
> WebView. What do I miss there?

There is no guarantee that a view generates its content by drawing it inside of 
-drawRect:. In the case of many views, content is contained in subviews rather 
than the view itself.

What you should do instead is have a webview as a subview and hide or show it 
as appropriate, and probably also pass first responder to it.

> 
> 
> Regards
> -- Leonardo
> 
> 
> _______________________________________________
> 
> Cocoa-dev mailing list ([email protected])
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/david.duncan%40apple.com
> 
> This email sent to [email protected]

--
David Duncan


_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to