Interaction with web javascript cocoa

2009-01-20 Thread Alex Mills
Hey, 

I have built a Javascript WYSIWYG editor. I want to build a WebKit based cocoa 
app with buttons that can call a function from the editor loaded in webkit. For 
example I want to have a button within the Cocoa interface that calls the 
Javascript function 'makeBold()' to make the selected text within the editor 
bold. If this is possible I then want to save the editor generated html to 
string so that I can store it within Core Data. I checked out the Apple Webkit 
programming guide but it doesn't provide much. 

Any help would be greatly appreciated.   

Cheers 
Alex Mills 
www.alexmillsdesign.com 


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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

This email sent to arch...@mail-archive.com


Re: Interaction with web javascript cocoa

2009-01-20 Thread Benjamin Dobson


On 20 Jan 2009, at 22:06:52, Alex Mills wrote:


Hey,

I have built a Javascript WYSIWYG editor. I want to build a WebKit  
based cocoa app with buttons that can call a function from the  
editor loaded in webkit. For example I want to have a button within  
the Cocoa interface that calls the Javascript function 'makeBold()'  
to make the selected text within the editor bold. If this is  
possible I then want to save the editor generated html to string so  
that I can store it within Core Data. I checked out the Apple Webkit  
programming guide but it doesn't provide much.


Any help would be greatly appreciated.

Cheers
Alex Mills
www.alexmillsdesign.com


I would assume you just send the web view to a javascript: URL, but I  
haven't even looked at the docs on this one.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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

This email sent to arch...@mail-archive.com


Re: Interaction with web javascript cocoa

2009-01-20 Thread Markus Spoettl

On Jan 20, 2009, at 11:06 PM, Alex Mills wrote:
I have built a Javascript WYSIWYG editor. I want to build a WebKit  
based cocoa app with buttons that can call a function from the  
editor loaded in webkit. For example I want to have a button within  
the Cocoa interface that calls the Javascript function 'makeBold()'  
to make the selected text within the editor bold. If this is  
possible I then want to save the editor generated html to string so  
that I can store it within Core Data. I checked out the Apple Webkit  
programming guide but it doesn't provide much.



Have a look at Using JavaScript From Objective-C in the WebKit  
Objective-C Programming Guide:


http://developer.apple.com/documentation/Cocoa/Conceptual/DisplayWebContent/Tasks/JavaScriptFromObjC.html#//apple_ref/doc/uid/30001214 



What it explains is how you can evaluate any JavaScript code from your  
app (which means calling functions too), you can also have JavaScript  
functions call back into your own Objective-C code.


Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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

This email sent to arch...@mail-archive.com

Re: Interaction with web javascript cocoa

2009-01-20 Thread Joseph Crawford
what i did is created the outlet to my webview, made the webview load  
an html file that contains all my JS functions and then call it like so.


	NSString *command = [[NSString alloc]  
initWithFormat:@addMarkerAtPoint(%f, %f, 13, \%...@\);, [location  
latitude], [location longitude], [location name]];

[mapOutlet sendMapCommand:command];

Now that sendMapCommand is a method I put in my mapController, here it  
is


-(void)sendMapCommand:(NSString *)cmd
{
id map = [mapView windowScriptObject];
[map evaluateWebScript:cmd];
}

The ONLY downfall to this is that you can only make 1 function call  
per command sent.  I tried to do seperate calls and it would not  
work.  Combining the calls into functions and making 1 function call  
has worked for me.


Thanks,
Joseph Crawford

On Jan 20, 2009, at 5:27 PM, Markus Spoettl wrote:


On Jan 20, 2009, at 11:06 PM, Alex Mills wrote:
I have built a Javascript WYSIWYG editor. I want to build a WebKit  
based cocoa app with buttons that can call a function from the  
editor loaded in webkit. For example I want to have a button within  
the Cocoa interface that calls the Javascript function 'makeBold()'  
to make the selected text within the editor bold. If this is  
possible I then want to save the editor generated html to string so  
that I can store it within Core Data. I checked out the Apple  
Webkit programming guide but it doesn't provide much.



Have a look at Using JavaScript From Objective-C in the WebKit  
Objective-C Programming Guide:


http://developer.apple.com/documentation/Cocoa/Conceptual/DisplayWebContent/Tasks/JavaScriptFromObjC.html#//apple_ref/doc/uid/30001214 



What it explains is how you can evaluate any JavaScript code from  
your app (which means calling functions too), you can also have  
JavaScript functions call back into your own Objective-C code.


Regards
Markus
--
__
Markus Spoettl

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/codebowl%40gmail.com

This email sent to codeb...@gmail.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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

This email sent to arch...@mail-archive.com