Read and Write to file, from Widget?

Yes.
Any widget that contains or stores data locally, does it on your hard drive. So for instance the data written in stickies widget will be read and written on your local hard drive.
But you probably had something a bit more specific in your mind if I'm not mistaken?
 
If you're talking about Dashboard widgets, then I'm not sure if they can or can't, but I would suspect that they cannot.

Dashboard widgets are typically written in Javascript, or a combination of Javascript and other typically web-based technologies. Javascript does not have access to the filesystem as another more low-level programming language might.
 
Hi!

I want to make a widget where I type in my name and it store that name in a text file. And I want the widget to read from another text file.

I have googeled around and I know it can be a little hard to make javascript do this, but since this is a local dashboard widget - I hoped there would be a solution for this?

Best,
Sigurd
 
What other applications do you need to use the content of those text files?

If it's only a few files you need to get read/written all the time, then the Stickies widget may be enough for you. Everything it stores is locally.

If it's something more complicated, the widget developer reference isn't a bad place to start (for even writing your own). The links are for 10.4 but they are essentially the same for 10.6.

http://developer.apple.com/mac/libr...//apple_ref/doc/uid/TP40001339-CH205-BAJCBIDE

Info.plist option
AllowFileAccessOutsideOfWidget
Optional; specify if your widget requires access to the file system outside of your widget. Access is limited by the user’s permissions

According to that one option alone, you could specify your widget to access a file outside it (as long as the user can access it).

http://developer.apple.com/macosx/dashboard.html
http://developer.apple.com/mac/library/navigation/index.html#topic=Guides&section=Resource+Types
http://developer.apple.com/mac/libr.../Dashboard_Ref/DashboardRef/DashboardRef.html

If there are only a few files that you want to use with Dashboard all the time, copy each to a separate sticky.
Those files can contain quite a bit of text, and you can have dozens of them, and minimize when not in use.
That way you don't have to worry about the files separately, just create stickies for whatever you need (e.g. I used about 20 different ones for frequently copy pasted material at work this way)
 
Dashboard widgets are typically written in Javascript, or a combination of Javascript and other typically web-based technologies. Javascript does not have access to the filesystem as another more low-level programming language might. ?
 
Back
Top