Recent Widgets


Register for DashboardWidgets

Recent Forums Posts

Partners


iCompositions

MacDesktops.net

RSS Showcase
RSS Comments
RSS Forums

This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. Posted in: Widget Development
Goto page 1, 2  Next

Error using a plugin

Author Message
Ryan



Joined: 30 Jan 2005
Posts: 3
Location: Seattle

Posted: Sun Jan 30, 2005 - 8:29 pm    Post subject: Error using a plugin Reply with quote

I am attempting to use a plug-in (written in Obj-C) with my Widget and I am having a lot of difficulty getting it to work properly.

I believe that I have everything setup correctly (I followed the instructions on-line and in the ADC documentation). The widget loads just fine.

Now for the weird stuff. Attempting to access any variables in my plug-in with javascript results in the following error:

'(event handler):Value undefined (result of expression myPluginName.nameOfVariable) s not object '

It does not seem to matter what I am attempting to read.

Has anyone else seen this problem and what do I do to correct it?

Thanks
-Ryan
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
below



Joined: 01 Feb 2005
Posts: 9
Location: Wiesbaden, Germany

Posted: Tue Feb 01, 2005 - 8:28 pm    Post subject: Reply with quote

Unfortunately, I have not been able to access an even trivial plugin. Are you aware of any sample code?

Also, while I am an experienced Cocoa Dev, I know little about JavaScript, so where can you check for such an error?

Thanks

Alex
View user's profile Send private message Send e-mail AIM Address Widgets
Ryan



Joined: 30 Jan 2005
Posts: 3
Location: Seattle

Posted: Thu Feb 03, 2005 - 4:30 pm    Post subject: Reply with quote

Unfortunately, the documentation on this kind of programming is very sparse. I simply used the posted website on dashboard development:
http://developer.apple.com/macosx/tiger/dashboard.html

The very bottom of the page shows the code that you need to get plug-ins to work.

Now, in order to view javasript errors, you need to enable debugging in Safari. I used Onyx to enable the debug menu:
http://www.versiontracker.com/dyn/moreinfo/macosx/20070[/url]
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
below



Joined: 01 Feb 2005
Posts: 9
Location: Wiesbaden, Germany

Posted: Thu Feb 03, 2005 - 5:32 pm    Post subject: Reply with quote

Thanks for the tips, but in the meantime I figured it all out. Some things are somewhat tricky, but now I can go on and do the fun **** Wink

Bye

Alex
View user's profile Send private message Send e-mail AIM Address Widgets
Ryan



Joined: 30 Jan 2005
Posts: 3
Location: Seattle

Posted: Fri Feb 04, 2005 - 11:45 am    Post subject: Reply with quote

Alex-
Your post implies that you have figured out how to get a plug-in working with a Dashboard widget.

If so, can you share your secrets/ source code?

Thanks
-Ryan
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
macrophyllum



Joined: 10 Feb 2005
Posts: 9
Location: Putney, VT

Posted: Thu Feb 10, 2005 - 5:15 pm    Post subject: Reply with quote

Yes, please share!
View user's profile Send private message Send e-mail Visit poster's website Widgets
below



Joined: 01 Feb 2005
Posts: 9
Location: Wiesbaden, Germany

Posted: Thu Feb 10, 2005 - 5:20 pm    Post subject: Reply with quote

Hello guys,

are you stuck at any specific point? I will try to get some hints together in the next few days. My widget is really that of a hard-core developer: It is entirely useless, except for showing a technical concept Wink

Alex
View user's profile Send private message Send e-mail AIM Address Widgets
macrophyllum



Joined: 10 Feb 2005
Posts: 9
Location: Putney, VT

Posted: Thu Feb 10, 2005 - 7:44 pm    Post subject: Reply with quote

I can't get my initWithWebView: method to get called and when I try to use my ScriptObject the Console says something like "MyScriptObject is not available", or some error. A useless widget that illustrates the plugin architecture would be TREMENDOUSLY helpful considering there is nothing like that available from Apple.
View user's profile Send private message Send e-mail Visit poster's website Widgets
Lynn



Joined: 04 Feb 2005
Posts: 3
Location: Seattle

Posted: Fri Feb 11, 2005 - 1:25 am    Post subject: Reply with quote

Has anyone seen any problems calling a plugin method with a parameter? I can easily call a method without parameters or a return value and also call a method with just a return value, but as soon as try something like:

var inputvalue = 1;
myObjCPlugin.callmymethod (inputvalue) it blows up.

Any thoughts would be greatly appreciated!
View user's profile Send private message Send e-mail AIM Address Widgets
below



Joined: 01 Feb 2005
Posts: 9
Location: Wiesbaden, Germany

Posted: Fri Feb 11, 2005 - 1:45 am    Post subject: Reply with quote

Two quick hints which were not in the documentation:

1) Some seeds did not find your plugin in /System/Library/WidgetPlugins, but only in your Plugin Bundle. Took me a while to figure that out

2) The selctor name for myMethod:(NSString *) myParameter is not myMethod, but myMethod:. By default, this is translated to myMethod_ for JScript. You can override this by returning a different name (say, myMethod) in scriptNameForSelector (did not look it up, but you know what I mean).
Likewise, the name for mySelectorWithOne:(NSString*)param1 andTwo:(NString *)param2 should by default get the name mySelectorWithOne_andTwo_ in JScript

More to come

Alex
View user's profile Send private message Send e-mail AIM Address Widgets
below



Joined: 01 Feb 2005
Posts: 9
Location: Wiesbaden, Germany

Posted: Mon Feb 14, 2005 - 11:32 am    Post subject: Reply with quote

Here is the code to my stupid widget plugin:

Code:
@implementation vbPluginClass
+ (NSString *)webScriptNameForSelector:(SEL)aSelector
{
// This is so we can call "test" in the JScript and don't have to use test_
   if (aSelector = @selector(test:))
      return @"test";
   else
      return nil;
}

- (id) initWithWebView:(WebView*)webview
{
   self = [super init]:
   return self;
}

- (void) windowScriptObjectAvailable:(WebScriptObject *)windowScriptObject
{
   [windowScriptObject setValue:self forKey:@"MyPlugin"];
}

- (NSString *) test:(NSString *)input
{
   NSBeep ();
   return @"4711";
}

+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector
{ return NO;}

+ (BOOL)isKeyExcludedFromWebScript:(const char *)name
{ return NO;}
@end


In your JScript then just use:
Code:
   if (window.MyPlugin)
   {
      var d = MyPlugin.test (x);
      // ...


Let me know if this has helped you, or if you have more questions!

Bye

Alex
View user's profile Send private message Send e-mail AIM Address Widgets
macrophyllum



Joined: 10 Feb 2005
Posts: 9
Location: Putney, VT

Posted: Fri Feb 18, 2005 - 11:30 am    Post subject: Reply with quote

Hi,

I have Tiger build where the plugins are in the widget bundle. I still can't get it to work, do you think you could post a test project where everything works, even if it is extremely trivial:-)?

On another note, the only way I can get my widget to load is by double-clicking it. If I put it in /Library/Widgets/ and restart it doesn't appear with the others. Anyone else experiencing this?

Kind Regards,
Ian
View user's profile Send private message Send e-mail Visit poster's website Widgets
below



Joined: 01 Feb 2005
Posts: 9
Location: Wiesbaden, Germany

Posted: Fri Feb 18, 2005 - 11:33 am    Post subject: Reply with quote

Common mistake: Is your widget plugin owned by root? That is something which must be done manually, or with an installer

HTH

Alex
View user's profile Send private message Send e-mail AIM Address Widgets
macrophyllum



Joined: 10 Feb 2005
Posts: 9
Location: Putney, VT

Posted: Fri Feb 18, 2005 - 11:43 am    Post subject: Reply with quote

That is a good question Smile

How do I set the owner as root?
View user's profile Send private message Send e-mail Visit poster's website Widgets
blurry
Quality Control


Joined: 03 Feb 2005
Posts: 33
Location: UK

Posted: Fri Feb 18, 2005 - 11:49 am    Post subject: Reply with quote

macrophyllum wrote:
How do I set the owner as root?


I think the following should work. We'll make a backup of the file first just in case.

Code:

cp MyCocoaPlugin.plugin MyCocoaPlugin.backup
sudo chown root:root MyCocoaPlugin.plugin


Enter your password, then we should be set. Check with:

Code:

ls -al | grep MyCocoaPlugin


George.
_________________
If your only tool is a hammer, everything looks like a nail
View user's profile Send private message Send e-mail Widgets
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

 
Goto page 1, 2  Next
Powered by phpBB © 2001, 2002 phpBB Group