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

Re: WebView drawRect


  • Subject: Re: WebView drawRect
  • From: David Duncan <email@hidden>
  • Date: Wed, 19 Mar 2014 12:54:37 -0700

On Mar 19, 2014, at 12:34 PM, Leonardo <email@hidden> 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@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

--
David Duncan


_______________________________________________

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: 
 >WebView drawRect (From: Leonardo <email@hidden>)

  • Prev by Date: WebView drawRect
  • Next by Date: Re: Does Apple modify our submitted binaries?
  • Previous by thread: WebView drawRect
  • Next by thread: Re: WebView drawRect
  • Index(es):
    • Date
    • Thread