Mailing Lists: Apple Mailing Lists

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

Re: Download Delegate and Print Button



You know, it's possible that we are talking about different things here.

I implemented the delegate method to handle file selection for the XHTML element type <input type="file" name="something" />. If I put one of those inside a form, then when I click it my delegate method gets called and I can put up the file selection panel.

Is this the case you are trying to handle? You refer to your "download link", so I now realize that you might be doing something totally different. In my case, all I'm doing is setting up the post data, and my form has a separate button ( <input type="submit" /> )that actually does something with the file name. (If this is what you are trying to do, then I'll ask the obvious technical support type of question: Did you remember to register as the UI delegate? You need this in addition to your other registrations.)

FWIW, I only support forms with method="get" and I intercept everything in decidePolicyForNavigationAction. That way the URL contains all of the form parameters and I can take a little detour to download a file if I need to.

And, last but not least, I have been writing software for a long time but I never wrote anything for a Mac before February and I didn't start developing with WebKit until about July (after ADC), so I'm not an expert by any means.

- Rush

Josh Ferguson wrote:
Rush,

I tried this but unfortunately it doesn't seem to be getting called. As
I said, my custom-rolled event loop is a little odd and I think it's
swallowing events somewhere. Here's what I'm seeing:

1.) I click on my download link.
2.) I get several calls to decidePolicyForNavigationAction:
4.) I get a call to decidePolicyForMIMEType:
5.) If webview can't display it, I tell it to ignore it and handle the
download manually.
5.) My WebView freezes. I no longer get any events. I can close the
window and move it around and that works fine...so it would seem my
event loop is still processing events. Is WebKit doing something strange
with the view when a download is encountered? Where should I be
intercepting the download so I can handle it myself?

Thanks for your help!

Josh

-----Original Message-----
From: Rush Manbert [mailto:email@hidden] Sent: Friday, December 09, 2005 12:11 PM
To: Josh Ferguson
Cc: email@hidden
Subject: Re: Download Delegate and Print Button


Josh Ferguson wrote:

I have a WebView window that I need complete control over and I'm

having


difficulty figuring out delegate methods to handle two situations. First, I need to intercept clicks for downloading files so that I can display my own File Open dialog. Essentially what's happening right

now


is that I've rolled my own event loop in order to make my webview

window


modal. When I need to display another window, I simply add that window


to my list of windows that can receive events (i.e. with links that

open


new windows). This must be causing the WebView to swallow the events that cause it to open the File Open dialog for downloads, as I get a Frame Load error when the download link is clicked. I have a feeling I'll need to create this dialog manually but I can't find a place to intercept this request. Any recommendations would be greatly

appreciated!

Hi Josh,

I don't know about the second one, but I have dealt with file selection from within my WebView. You need to implement the WebUIDelegate method
- (void)webView:(WebView *)sender runOpenPanelForFileButtonWithResultListener:(id<WebOpenPanelResultListen
er>)resultListener



Here's mine, for what it's worth:
- (void)webView:(WebView *)sender runOpenPanelForFileButtonWithResultListener:(id<WebOpenPanelResultListen
er>)resultListener
{
NSOpenPanel *panel = [NSOpenPanel openPanel];
int i = [panel runModalForDirectory:NSHomeDirectory()
file:nil
types:nil];

if (i == NSOKButton)
{
[resultListener chooseFilename:[[panel filenames]
objectAtIndex:0]];
}
}


Remember to register as the delegate by sending
[myWebView setUIDelegate:self]
in your window controller.

- Rush


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

This email sent to email@hidden
References: 
 >RE: Download Delegate and Print Button (From: "Josh Ferguson" <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.