David S has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to use XUL::Gui and I would like to be able to call a sub when the window is loaded. I have the following code, but the WindowLoaded() sub does not get called. Does anyone know the proper way to get onload to work for a window?

Thanks, David

use XUL::Gui; display Window ( onload => \&WindowLoaded, id => "window", title => "Test Window", Button(label=>'Test', oncommand=>\&ButtonHandler) ); sub WindowLoaded { print "in WindowLoaded\n"; } sub ButtonHandler { print "in ButtonHandler\n"; }

Replies are listed 'Best First'.
Re: XUL::Gui onload
by toolic (Bishop) on Jan 23, 2011 at 01:12 UTC
      Yes, I posted a question/bug there and since I hadn't heard back I thought I'd ask here. I've gotten help here in the past and hoped to get help again.
Re: XUL::Gui onload
by PeterPeiGuo (Hermit) on Jan 23, 2011 at 22:45 UTC

    Your code was fine (at least with strawberry perl and XUL::Gui 0.20). The WindowLoaded method was called, and the message did show up in the command window (not in the browser though, just in case that's where you checked).

    Peter (Guo) Pei

      Thanks. Yes, expected the message to be in the command window. Doesn't work with AS Perl 5.8.8 and XUL::Gui 0.63.