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

Picture changes depending on preferences?

Author Message
Tovi



Joined: 04 May 2005
Posts: 7
Location: Chicago

Posted: Wed May 04, 2005 - 6:43 pm    Post subject: Picture changes depending on preferences? Reply with quote

Greetings...

I've swear I've spent more than 10 hours trying to figure out how to develop a widget. I'm an avid PHP programmer but Javascript has me dumbfounded. I have been able to get as far as now hacking my way with other people's scripts, especially the ones provided by Apple.

I finally was able to make my widget flip and provide the user with some options from a drop down menu.

I was also able to have a link on the front of the widget change depending on the preferences selected.

What I haven't been able to do is have a picture in front of the widget change, depending on those same preferences.

Any ideas??

This is what I have on the JS page:
Code:
function DrawMap(address)

   var returnStructure = "";
   
   returnStructure += "<img src='" + address + "'>";
   returnStructure += "</img>";

   //display map
   document.getElementById('map').innerHTML = returnStructure;
}


And this on my html page:
Code:
<div id="map" class="map" onclick="wrapURL();"></div>


When I flip the widget after selecting the preferences, no image shows up but I can click on where it's supposed to be and Safari opens.

This is the css:
Code:
.map
{
position: absolute;
width: 150px;
height: 101px;
}

#map
{
   top: 46px;
   left: 26px;
}
View user's profile Send private message Widgets
sean



Joined: 22 Apr 2005
Posts: 67
Location: Duluth, MN

Posted: Wed May 04, 2005 - 7:03 pm    Post subject: Reply with quote

The problem could be that you haven't allowed network address, try adding this to your Info.plist:

<key>AllowNetworkAccess</key>
<true/>

If that's already set, you could try setting the source of an image element directly, like this:

html:

<img id="map" src="" onclick="wrapURL();"></img>

Javascript:

Code:
function DrawMap(address) {
   document.getElementById('map').src = address;
}
[/code]
View user's profile Send private message Send e-mail Visit poster's website Widgets
Tovi



Joined: 04 May 2005
Posts: 7
Location: Chicago

Posted: Wed May 04, 2005 - 7:41 pm    Post subject: Reply with quote

Thanks for the help.. I was able to get the images to show up this way.

Now, they only change after I refresh the widget. Any help on how I can get the widget to refresh after returning from the back (preferences side) to the front (images side)?

thanks
View user's profile Send private message Widgets
sean



Joined: 22 Apr 2005
Posts: 67
Location: Duluth, MN

Posted: Wed May 04, 2005 - 7:53 pm    Post subject: Reply with quote

You could call the DrawMap function every time you switch to the front of the widget. I assume your 'Done' button calls the showFront function, or something similar, right? Does it refresh the image if you call DrawMap from within that function?
View user's profile Send private message Send e-mail Visit poster's website Widgets
Tovi



Joined: 04 May 2005
Posts: 7
Location: Chicago

Posted: Wed May 04, 2005 - 8:12 pm    Post subject: Reply with quote

Thanks a lot !!!

I had to add some extra code but that worked great.

You'll be seeing me here more often since I have the widget dev bug. As soon as I feel its up to the sites standards I'll post it.
View user's profile Send private message 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