WebView woes

I have been working on a little blog posting app for my wife for some time called BlogThing.  The first version worked well enough that I released it for download from the Automagic Software site.  It used some pretty nasty stuff that iterated over the chunks in an NSAttributedString, and while it worked pretty well I decided I wanted something a little more future proof.  To that end I decided to look into using WebView in edit mode.  Under 10.4 this worked really nicely.  I could drag in imanges, set the fonts and do all sorts of really neat things.  Unfortunately under 10.5 dragging and pasting images into the blog posting just stopped working 🙁 and I’ve not had a lot of time to look into it.  Tonight I’ve managed to get it working well enough that I think I can finally give it to my wife to play with.

The following is an example of what I’ve had to do to get dragging to work the way I want it do.  I really don’t like it though

– (unsigned)webView:(WebView *)sender dragDestinationActionMaskForDraggingInfo:(id <NSDraggingInfo>)draggingInfo {

NSPasteboard* pb = [draggingInfo draggingPasteboard];

if([pb availableTypeFromArray: [NSArray arrayWithObject: NSFilenamesPboardType]]) {

// @TODO: this code assumes that any file dragged in is an image!  Bad things will probably happen if they aren’t

NSArray* filenames = [pb propertyListForType: NSFilenamesPboardType];

NSMutableString* html = [NSMutableString string];

for(NSString* filename in filenames) {

[html appendFormat: @”<img src=\”%@\”/>”, [[[NSURL alloc] initFileURLWithPath: filename] absoluteString]];

}

[pb declareTypes: [NSArray arrayWithObject: NSHTMLPboardType] owner: self];

[pb setString: html forType: NSHTMLPboardType];

}

return WebDragDestinationActionAny;

}

Incidentally I’m posting this with BlogThing 2.0

Join the Conversation

1 Comment

  1. I hope this is the right place to get answers or solutions. I have tried posting before but perhaps I wasn’t here on the current blog.

    My issues are as follows. G4 Laptop Running 10.4.11. HttpPluggin 1.49

    For some reason within the last month or so, the Mail.app runs through it’s motions. If I have any of my http mail boxes highlighted while retrieving mail, then all the mail shows up in the viewer window and I can read the downloaded emails. If by chance no http mail box is selected, then it will show that it has retrieved mail into the http folders, but as soon as I highlight any of the http mailboxes showing new messages, all messages DISAPPEAR! I have to constantly rebuild the mailbox only to have it repeat the same thing in an endless loop. It is driving me nuts!!!!!!!

    I really can’t afford to upgrade to Leopard at this time and I could really use this plugin to be working correctly . I have tried any and all of the various suggestions that I have found here withing your blogs 9even though no one has said they have the exact same problem), but nothing works at all.

    Any insight or help you can give me on this would be an amazing blessing. I have tried uninstalling and reinstalling to no avail. Trashed prefs, caches…you name it. I have no idea why all of a sudden it has stooped working. I cannot remember if there was an upgrade between the one I am using now and the 1.46 from my Panther machine as I think it occurred after an update. I just found the 1.47 and 1.48 I will try and see if they work.

    Sorry one more thing. The Mail.app doesn’t seem to want to remember any of the http preferences. YOu can set them and if you quit mail and reopen all the changes made revert.

    Best wshes and thank for a great product.

    JD

    Update: 04/20/08 After going back to version 1.48 the problem still exists. It’s strange… if I select the mail box (http) right click and select get info, the window opens stating there are tons of messages in the mailbox, however if I select “show messages” it shows no messages at all and states 0 messages in folder. Any thoughts or help at all?

    Thanks again.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.