The first half of this tutorial introduced you to making a rudimentary but functional widget of the sort you can find on Yahoo's site since its purchase of Konfabulator. In this article, you'll add the finishing touches to increase its functionality.
Widget Walkthrough - Fine tuning headline retrieval (Page 4 of 5 )
If you save the changes and reload the file now, the headlines should appear as if by magic! Using the <textarea> is good because it makes setting the preferences easy and handles the word wrapping well. One major flaw of this though is that it's not possible to set the URL of each individual headline. To compensate for this, you can add a right-click menu item to the widget that takes you to either the main news front page, or a page containing the list of headlines displayed. To do this, you can add the following code block to the <textarea> element:
<contextMenuItems> <menuItem title="Open BBC Technology News"> <onSelect>openURL ("http://news.bbc.co.uk/1/hi/technology/default.stm");</onSelect> </menuItem> <menuItem title="Open the actual headlines page"> <onSelect>openURL (http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/technology/rss.xml); </onSelect> </menuitem> </contextMenuItems>
This at least provides you with a way of reading the full news stories. Another thing that you need to consider is a way of updating the file used as the source of the data; if the computer and widget are left running, the reader will just display the same data, forever. A timer element can be used to specify that an action could be carried out repeatedly on a set interval:
The interval is measured in seconds, but this kind of widget wouldn't really need to grab a new rss file every ten seconds. Depending on the frequency of updates at the source, you could probably set it to update maybe several times daily.