in reply to Tk fullscreen mainwindow key bindings

I believe it's a bug. I noticed that if I hit control-c, the underlying window would have focus and kill the window. I grepped thru the Tk-804.027_502 distribution for Fullscreen and came up with interesting items
local $TODO = "-alpha and -fullscreen not yet implemented"; Getting fullscreen attribute is not yet implemented for X11 {setting/unsetting fullscreen does not change the focus} {change -fullscreen after map}); # Query above should not clear fullscreen state and many more such hits
So..... probably there is a problem with focus changing after mapping the $mw. Interestingly enough, you can't even use Fullscreen after the $mw is mapped
#!/usr/bin/perl use Tk; my $mw = new MainWindow; $mw->after(10,sub { $mw->FullScreen(1); $mw->bind('all'=> '<Key-Escape>' => sub {exit;}); $mw->focusForce; $mw->update; }); MainLoop;
Maybe there has been a fix in Tk-804.028, but I see nothing in the changelog. So there are a couple of hacks you can use:
#!/usr/bin/perl use Tk; my $mw = new MainWindow; $mw->bind('all' => '<Key-Escape>' => sub {exit;}); $mw->FullScreen(1); $mw->grabGlobal; $mw->focusForce; MainLoop;
or better yet, to avoid the globalgrab, use the old fashioned way of setting geometry for the $mw
#!/usr/bin/perl use Tk; my $mw = new MainWindow; $mw->geometry($mw->screenwidth . 'x' . $mw->screenheight . '+0+0'); $mw->bind('all' => '<Key-Escape>' => sub {exit;}); MainLoop;
I guess the lesson is, don't count on Fullscreen working. Use the geometry instead. Maybe Slaven Rezic will see this and chime in, as he is the current owner of Tk and knows the xs for converting from the tcl.

I'm not really a human, but I play one on earth Remember How Lucky You Are

Replies are listed 'Best First'.
Re^2: Tk fullscreen mainwindow key bindings
by rocklee (Beadle) on Nov 02, 2008 at 17:48 UTC
    grabGlobal did the trick - I want a borderless fullscreen window (as the end-user will never be exposed to the underlying system). Thanks yet again :-)