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

Images Swapping too Quickly

Author Message
Quill



Joined: 23 Feb 2007
Posts: 11

Posted: Sat Feb 24, 2007 - 2:10 am    Post subject: Images Swapping too Quickly Reply with quote

EDIT: I found the problem! I simply had to add this line to the style identifying the button in the Cascading Style Sheet:
Code:
-apple-dashboard-region: dashboard-region(control rectangle);


Hello,

I have a button in my widget (an image) which I would like to change to another image when clicked.

I looked at one of Apple's default widgets—the Translator—and saw how they changed their <swap> button. I copied the relevant code into my widget and tested it in Safari, where it worked fine. In Dashboard, however, the button either swapped images for a spit second or not at all (both undesirable).

Would this be because, in Dashboard, the speed at which the image changes is too fast for the human eye to detect? If so, is there some code that will make sure the clicked button image stays on for at least ~ 0.5 seconds, or is there an entirely different problem?....

Here's the HTML/Javascript code (the entire widget can be downloaded here):

Code:
<html>
<head>

<style type="text/css">
   @import "formatting.css";
</style>

<SCRIPT LANGUAGE="Javascript" TYPE="text/javascript">
<!--


document.write('<div id="WeatherMap"><img src="http://www.bom.gov.au/fwo/IDY00050.gif"></div>');


function reLoad()
{
   location.reload()
}

function swapMouseDown()
{
    document.getElementById('refreshButton').src = 'RefreshButtonClicked.png';
}

function swapMouseUp()
{
    document.getElementById('refreshButton').src = 'RefreshButton.png';
}


// -->
</script>

</head>

<body background="Default.png">

<img src="RefreshButton.png" id="refreshButton" onMouseDown="swapMouseDown(event);" onMouseUp="swapMouseUp(event);" />


</body>
</html>

Thanks,
Quill
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