onSettingsClosing, onFocus and other events...
I have a problem (with one solution), where the following happens...
Ok desired chain on events:
Gadget displays some text based on XML
Settings window opened
Settings changed
Settings window closed
Gadget displays some different text based on different XML
What's happening:
Gadget displays some text based on XML
Settings window opened
Settings changed
Settings window closed
Gadget displays same text...
A quick test drop out of the onSettingsClosing event to set the text in the gadget to a "Hello World" value, causes an error and the settings window won't shut. So I'm guessing that the element in the gadget I'm trying to set isn't available yet, as we're still in the settings window as such even though it's closing. However that's less of a problem, what I really want to is know definitively when the settings window has closed and I can update my gadget.
The onfocus event of the gadget's body is one solution, but this fires the whole time and I have to disgregard the times it fires and I'm not interested. Is there another event fired I can grab or a better way of knowing that the gadget is back in "focus" after the settings window closes, or is onfocus as good as it gets?
Chris
[1324 byte] By [
Chrisull] at [2008-2-15]
>>The onfocus event of the gadget's body is one solution
Actually looking at it more, it isn't a solution, because it doesn't necessarily get the focus when the settings window closes, unless the user actively intervenes. I'm looking for settingsclosed -> event fired immediately changing contents of gadget which still seems tantalisingly out of reach.
Chris
Your settings.html wants to look something like this:
System.Gadget.onSettingsClosing = SettingsClosing;
function SettingsClosing(event) {
if (event.closeAction == event.Action.commit) {
System.Gadget.Settings.write("Caption", eCaption.value);
}
event.cancel = false;
}
function init() {
eCaption.value = System.Gadget.Settings.read("Caption");
}
Your settings.html body like this:
<body onload="init()">
Caption:
<input type="text" id="eCaption" title="Caption text" >
</body>
And your gadget.html like this:
System.Gadget.settingsUI = "Settings.html";
System.Gadget.onSettingsClosed = SettingsClosed;
function SettingsClosed() {
caption = System.Gadget.Settings.read("Caption");
//update gadget code
}
Thanks Jonathan once again for your help.
>>Your settings.html wants to look something like this:
<snip>
The problem seemed was that SettingsClosed() never got raised. My code was very similar, except for a small "s" sigh - spot the easy to miss mistake!
System.Gadget.settingsUI = "Settings.html";
System.Gadget.onSettingsClosed = settingsClosed;
function SettingsClosed() {
}
Chris