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

Testing widgets in Safari: can't find variable error.

Author Message
jax



Joined: 03 May 2005
Posts: 17
Location: Montreal

Posted: Tue May 03, 2005 - 8:18 am    Post subject: Testing widgets in Safari: can't find variable error. Reply with quote

I read that you're supposed to be able to test Dashboard widgets in Safari. When I test APple's widgets, they work great. When I test my own widgets that I'm designing, or some other ones I got off the net, I get the following error in console...

(event handler):Can't find variable: widget

The widgets work fine in Dashboard though, just not in Safari! In safari, my widget loads about half way and then gets stuck, and the "i" that you click to go into preferences does nothing. Does anybody know what is wrong, or how to fix it?
View user's profile Send private message Send e-mail Visit poster's website Widgets
draino



Joined: 26 Apr 2005
Posts: 11

Posted: Tue May 03, 2005 - 6:05 pm    Post subject: Reply with quote

Your probably using the widget.system call or something like it. That's not supported in Safari.
View user's profile Send private message Send e-mail Widgets
kps



Joined: 03 May 2005
Posts: 10
Location: Waterloo, ON, Canada

Posted: Tue May 03, 2005 - 6:40 pm    Post subject: Reply with quote

"widget" is only available in Dashboard, so you either just put up with the errors while testing, or wrap the use, like this example from Apple:
Code:
if (window.widget)
      setTimeout('widget.performTransition();', 0);

http://developer.apple.com/documentation/AppleApplications/Conceptual/Dashboard_Tutorial/Preferences/chapter_5_section_3.html
View user's profile Send private message Send e-mail Visit poster's website Widgets
jax



Joined: 03 May 2005
Posts: 17
Location: Montreal

Posted: Fri May 06, 2005 - 7:45 am    Post subject: Reply with quote

Thanks so much for your help! So what will that setTimeout actually do in this case? If window.widget is true if the widget is running in dashboard, right ? so do I need an else to tell it what to do if it's running in safari?
View user's profile Send private message Send e-mail Visit poster's website Widgets
kps



Joined: 03 May 2005
Posts: 10
Location: Waterloo, ON, Canada

Posted: Fri May 06, 2005 - 8:13 am    Post subject: Reply with quote

In that particular example, from Apple's sample code to flip sides,
Code:
    if (window.widget)
        widget.prepareForTransition("ToBack");
               
    // Draw the back
    ...
           
    if (window.widget)
        setTimeout ('widget.performTransition();', 0); 

the first widget use tells Dashboard that, instead of immediately displaying whatever you do to display your reverse side, it should record it off-screen. The second performs the 'flip' animation using this new off-screen copy. (I believe it's wrapped inside a setTimeout because it mustn't be done from within an event call [i.e the button click], but Apple doesn't explain that.)

In this case, you don't do anything in Safari, and you just get your stuff shown immediately, with no animation.

Likewise for most uses of "widget", you don't or can't do anything when not in the Dashboard, so whatever feature you're using just won't work in Safari.

There are a few cases where you can do something different and useful in Safari (or other browser), e.g.
Code:
    if (window.widget)
        widget.openURL(url);
    else
        window.open(url, "_blank");
View user's profile Send private message Send e-mail Visit poster's website Widgets
jax



Joined: 03 May 2005
Posts: 17
Location: Montreal

Posted: Fri May 06, 2005 - 5:58 pm    Post subject: Reply with quote

Cool, thanks a lot for your help!
View user's profile Send private message Send e-mail Visit poster's website Widgets
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

 
Powered by phpBB © 2001, 2002 phpBB Group