[Project_owners] How to focus <dialog/> ?

Matthew Waymost waymost at gmail.com
Sat Jan 28 10:13:03 EST 2006


I'll have to go back and see if I have the same problem...

I took a look at the nsIWindowMediator interface (
http://www.xulplanet.com/references/xpcomref/ifaces/nsIWindowMediator.html),
and the only other thing I can come with is to use getXULWindowEnumerator
with your window type, verify you can focus it |if (window &
!window.closed())|, and then call the focus method on it. I *think* that
using the XULWindowEnumerator may get around that modal dialog that's seems
to be tripping you up.

Matt

On 1/28/06, Eric H. Jung <grimholtz at yahoo.com> wrote:
>
> Hi Matt,
>
> Yes, that is precisely what I do... and it works when the options
> window isn't itself displaying a modal dialog. However, if, for
> example, the About Box is displaying on top of the options window, this
> code doesn't work for me.
>
>
> --- Matthew Waymost <waymost at gmail.com> wrote:
>
> > I use the code below for my own options dialog, and I've never had a
> > problem
> > with it.
> >
> > var optionsWindow = ForwardFork.mediator.getMostRecentWindow
> > ("forwardfork:options");
> >
> > // if its open, focus it; otherwise, open it
> > if (optionsWindow && !optionsWindow.closed)
> > optionsWindow.document.commandDispatcher.focusedWindow.focus();
> > else optionsWindow =
> >
> window.openDialog
> ("chrome://forwardfork/content/forwardForkPrefs.xul","ForwardFork
> > Options","chrome,centerscreen,resizable");
> >
> > Basically, you have to make sure a window (or dialog) )exists and
> > that it
> > isn't closed. Then, based on that, you decide whether to refocus an
> > open
> > dialog or open a new one.
> >
> > HTH, Matt
> >
> > On 1/28/06, Eric H. Jung <grimholtz at yahoo.com> wrote:
> > >
> > > Hi,
> > >
> > > I asked this question here
> > > http://forums.mozillazine.org/viewtopic.php?t=373278 but that
> > didn't
> > > help...
> > >
> > > I'm using this code to focus/activate/bring-to-top both <window/>
> > and
> > > <dialog/> elements:
> > >
> > > Components.classes["@mozilla.org/appshell/window-mediator;1"]
> > >   .getService(Components.interfaces.nsIWindowMediator)
> > >   .getMostRecentWindow("passwordmaker")
> > >   .focus();
> > >
> > > It works if getMostRecentWindow() returns a <window/>, but if it
> > > returns a modal <dialog/>, I get this exception:
> > >
> > > "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)
> > > [nsIDOMWindowInternal.focus]"  nsresult: "0x80004005
> > >
> > > I'm using windowtype="passwordmaker" as a dialog attribute. Anyone
> > know
> > > what I'm doing wrong?
> > >
> > > Thank you,
> > > Eric Jung
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam?  Yahoo! Mail has the best spam protection around
> > > http://mail.yahoo.com
> > > _______________________________________________
> > > Project_owners mailing list
> > > Project_owners at mozdev.org
> > > http://mozdev.org/mailman/listinfo/project_owners
> > >
> > > _______________________________________________
> > Project_owners mailing list
> > Project_owners at mozdev.org
> > http://mozdev.org/mailman/listinfo/project_owners
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mozdev.org/pipermail/project_owners/attachments/20060128/8d736bd5/attachment.htm


More information about the Project_owners mailing list