How to use WebView to partly show website content (like Web Clip + Dashboard)

Discussion in 'Mac Programming' started by spotlite, Feb 18, 2008.

  1. macrumors newbie

    Joined:
    Jan 28, 2008
    #1
    Hello everyone,

    I am using WebView on an application I am developing. A small section of the application is a WebView object. I am having the WebView load a URL, and that is working fine, and as you would expect, it's showing the top-left corner of this website. I want to focus on a very specific area of this website, without having to use scroll bars to move. Very similar to what Web Clip does for Dashboard, but built into my native app. I'm using Xcode + IB + Cocoa.

    Is this possible? What would be the best way of doing it? I've looked at the documentation, but have had no luck.

    Thank you in advance.
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
  3. thread starter macrumors newbie

    Joined:
    Jan 28, 2008
    #3
    I don't understand how you would use a NSClip to actually have the WebView show something other than the top-left most corner of the website. I want to have the origin be something else on the site, without the need to have scroll bars. If it's possibly to do this by putting it in a NSClip, could you please elaborate on how to do it? Thank you.
     
  4. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    NSClipView does not display scrollbars: that's what an NSScrollView does. NSScrollView uses and embeded NSClipView to clip the whole view for display. This is basically what you want to do.

    So I'd:

    1) Create an NSClipView (of the size you want)
    2) Set the document view to your web view
    3) Scroll to point to set the displayed section of the view to what you want.
     
  5. thread starter macrumors newbie

    Joined:
    Jan 28, 2008
    #5
    Got it! Thanks or your help.
     

Share This Page