Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: easiest way to show alertbox and play sound from a wiget?



An important note on this, that I believe affects the original poster's concerns.  While you can display a dialog & play a sound, it must be attached to an application, not to the "desktop" as originally asked.  The Finder is the closest match to the "desktop", but it is still an independent application.  Therefore, there is no guarantee of focus when attaching an alert to it.  For instance, if the user was using Mail & you told Finder to display a dialog, Finder won't take focus from Mail.  All that will happen is that the Finder's Dock icon will bounce.  Once the user switches focus to the Finder, they would see the alert box.  From a UI perspective, that doesn't make much sense in this application, since the Finder doesn't have a clear connection to that particular widget in the Dashboard.  Ideally, you'd have the Dashboard icon bounce, but since that can be removed from the dock, it's not a viable alternative.

As Micah, suggested, a widget shouldn't consume any CPU when it isn't shown, so perhaps a widget isn't the proper environment for the application the original poster is trying to create.  Dashboard is intended for on-demand applications, not daemons.  However, you can use Dashboard as a view of the daemon.  There are several widgets that are good examples of this, such as those that read system load.  In that case, the widget isn't doing the processing, but is merely displaying the output from the application doing the processing.  I'd suggest that if the application can't gather the data the user needs before they hide the dashboard, it wasn't that important to them anyway.  In that case, the complexity of the processing probably would be better served by a compiled application, like Java, or even better Obj-C, rather than _javascript_.

Good luck,

Niels

On May 31, 2005, at 3:09 PM, Guy Brooker wrote:


As Micah says, you can play a sound using an embedded object, but you need to enable
AllowInternetPlugins in your Info.plist to make it work from _javascript_.

To show a dialog, use a bit of AppleScript via a widget.system call, e.g:

osascript -e 'tell application "Finder" to  display dialog "hello"'

You could also play the sound from the applescript too...

Cheers
Guy

Micah Acinapura <email@hidden> wrote:

I will refer you to this line: "A widget can know when Dashboard is active. When Dashboard is hidden, your widget should not consume any CPU time or network resources."

of this site: http://developer.apple.com/documentation/AppleApplications/Conceptual/Dashboard_Tutorial/index.html <http://developer.apple.com/documentation/AppleApplications/Conceptual/Dashboard_Tutorial/index.html>

when this is the case you might not to make your program a widget.

That being said, here is my code for how to make a widget play sound ( i don't know/haven't tried the alert box issue).

//_javascript_ code
function playNext(){
  var thissound=document.getElementById("next");
  thissound.Play();
}

//html code
<embed src="" autostart=false hidden=true id="next" enablejavascript="true" />

-micah

On May 31, 2005, at 8:32 AM, Walfrieda Schröter wrote:
Hi,
I am developing a widget that runs in the background, but NEEDS to show a 
customized alertbox/infobox upon a certain event and play a sound (kind of 
"Hi, something has just happend!"). It should not bring up Dashboard, but 
only the alertbox on the normal desktop, with an "OK" button to dismiss 
the box.
What would be the most simple and straightforward way to code that? 
Apparently is does not work directly via _javascript_ (all alerts are 
written to the console then, I use this routinely for debugging), so maybe 
this could be achieved by a simple script or something that can be called 
from within the widget? How is it done?


thanks a lot in advance for all kinds of advice,
walli

-- 
Geschenkt: 3 Monate GMX ProMail gratis + 3 Ausgaben stern gratis
++ Jetzt anmelden & testen ++
http://www.gmx.net/de/go/promail <http://www.gmx.net/de/go/promail> ++
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Dashboard-dev mailing list      (
email@hidden <mailto:email@hidden> )
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/dashboard-dev/email@hidden

This email sent to
email@hidden <mailto:email@hidden>




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Dashboard-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/dashboard-dev/email@hidden

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Dashboard-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Dashboard-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/dashboard-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.