I have a gadget that navigates through a set of XML documents via next/previous buttons. Some of these documents link to a first page with windows media player attached to play an associated video, while some link to a second page which doesn't contain a video. You can navigate backwards and forwards through these pages of the first type, without trouble, but when you click on a link which jumps to the second page, from the first, then you lose the "focus" (I say focus warily, because I realise that actually losing focus would mean that the flyout would close, which it doesn't).
What happens is that the sidebar gadget has the focus, and you have to click on the flyout twice (the first time regains focus, the second time then activate the links as normal). You can then continue navigating via links from the second page to the second page, but if I come to a link that jumps back to the first, once again, the sidebar resumes "focus". I'm sure this is what is happening as I can see the sidebar goes from a slightly gray background, to a totally clear one. Likewise the flyout has a filmy gray cover indicating when it has "lost focus". This is the RTM version of Vista, and all other parts of the app work correctly, so I assume this is normal behaviour. Is there anyway of grabbing focus back
I was going to debug to see at what point "focus" is gained when the gadget starts, but the manifesturl solution just yield "oops this feed isn't working", even though I have added *.start.com to my trusted sites.
Chris

Flyout to the front?
jan3784
<body onLoad="self.focus();">
or
self.focus();
document.body.focus();
There was a few issues with flyout focus during the beta, such as focus not being set correctly when using Windows Classic GUI, not sure if it got fixed though.
kiran1234
No, thanks for the offer but I can repro the bug fine.
SoundsGoodToMe
Would you like me to send you a Repro
wencey
>>or
>> self.focus();
>> document.body.focus();
I tried this but no luck. Also I've tried just using a single flyout page and dynamically assigning the background image via the DOM depending on whether or not the document has an associated video, and this also has the same problem. Any further suggestions are welcomed.
Regards,
Chris
Dee_dotnet_79
1. Changing the Flyout from within the Flyout will cause strange results as the code past the ".Flyout.file = " line may not run. You need to move that code to the Gadget and call it from the Flyout via "System.Gadget.document.parentWindow.showFlyout(...);"
You can reference the Flyout variables via "System.Gadget.Flyout.document.parentWindow.<variable>"
2. You're not closing the existing Flyout first, which seems to cause focus to go back to the Gadget. Close the open flyout and then pause before opening the next. ie:
function showFlyout() {
if(System.Gadget.Flyout.show)
System.Gadget.Flyout.show=false;
System.Gadget.Flyout.file = "<...>.html";
setTimeout("showit()", 200);
}
function showit() {System.Gadget.Flyout.show=true}
I had all kinds of issues with Flyouts not appearing correctly during the beta, 200ms seemed to be the minimum you could wait before showing it after it had changed.
I'll have a play around to see if the focus can be forced back to the Flyout, without closing it first
Scott Dorman
Prakash selvaraj
Thanks Jonathan, your fix has sorted the issue for me. It's still kind of flickery when I load a "different" window, but I suppose there's not much I can do about that
Chris
TheViewMaster
>>If you can, show me the code that initially opens the Flyout, and the code that changes it.
See below.
>>Also, is the code that changes the Flyout within the Flyout/called from the Flyout or is it in the >>Gadget
The if statement works, while the else if one loses focus.
In the Flyout.
Code that opens the flyout:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
function
showFlyout (nextstory, filename, link, timeout){
if (link !=-1){
System.Gadget.document.parentWindow.current = link;
}
if (System.Gadget.Flyout.show == false){
System.Gadget.Flyout.file = filename +
"Flyout.html";System.Gadget.Flyout.show =
true; //System.Gadget.Flyout.document.body.focus = true; if ( timeout > 0 ){
setTimeout(
"hideFlyout();", timeout);}
}
else if ((System.Gadget.Flyout.show == true) && (nextstory=="1")){
System.Gadget.Flyout.file = filename +
"Flyout.html";System.Gadget.Flyout.show =
true; //System.Gadget.Flyout.document.body.focus = true; if ( timeout > 0 )setTimeout(
"hideFlyout();", timeout);}
else{
hideFlyout() ;
}
if ( window.event != null ){
window.
event.cancelBubble = true ;window.
event.returnValue = false;}
}
Code that changes the flyout - it's the call of showFlyout in the code below there that is to blame. It can either be set to video or novideo. Loadstory then sets XML content, but it is called identically by the code at all times.
>>>>
var stories2 = System.Gadget.document.parentWindow.stories; var current2 = System.Gadget.document.parentWindow.current; var filenamenew = System.Gadget.document.parentWindow.filename;current2++;
if (current2==stories2.length){
current2=0;
}
System.Gadget.document.parentWindow.current = current2;
if(filenamenew[current2]!="false"){
showFlyout(
"1", "video", -1);}
loadStory();
Regards,
Chris
Nigel Harper
Also, is the code that changes the Flyout within the Flyout/called from the Flyout or is it in the Gadget
LeeC22
Jonathan,
That totally fixed my problem with resizing a flyout too. You are my hero! My resize feature is back on!
fyi... I'd change your code to say setTimeout(getFocus, 300); (i.e. no quotes or parenthesis). The way you have it, it's doing an eval() of the string and as we all know, eval=evil unless you can't avoid it, and you can in this case.
Anyway... Thanks again for the fix! As your lame reward, I've credited you in my code comments.
ChandraP
On my PC the quickest I can set focus back is 300ms. Simply add the following code to the very end of the Flyout.html:
<script language="javascript" type="text/javascript">
setTimeout("getFocus()", 300);
function getFocus() {self.focus()}
</script>