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

Hey all, i am trying to use the Tk::MatchEntry module with a window that is always on top. The problem is that the popup list for Tk::MatchEntry is hidden under the window when the user types. Do you all have any suggestions?

Attempts to fix include:

Background:

Example Code
use Tk; require Tk::StayOnTop; require Tk::MatchEntry; $desc = ""; @opts = ("test","one","two","three"); $window = MainWindow->new; $window->Button(-text => "Button")->grid(-row=>1,-column=>0); $Entry = $window->MatchEntry(-textvariable => \$desc)->grid(-row=>0,-c +olumn=>0); $Entry->choices(\@opts); #$window->after(1000,sub {$window->attributes(-topmost => 1)}); $window->after(1000,sub {$window->stayOnTop()}); MainLoop;

Replies are listed 'Best First'.
Re: Help preventing Tk::StayOnTop from hiding Tk::MatchEntry pop up list
by imbeyondboredom (Initiate) on Jul 01, 2009 at 17:13 UTC

    I found a solution but I don't like it...

    It turns out that Tk::stayOnTop uses the -topmost attribute of the Tk window if it's available. Otherwise, it uses the Win32::API module to mess around with the window properties.

    As you will see below, I figured that I could set the window to be out of topmost mode when in focus and out of topmost when in focus. The problem is that when using the topmost attribute approach the window goes out of focus so the user would not be typing in the box anymore. If one comments out the line that checks for the topmost attribute in Tk::StayOnTop then it forces it to use the Win32::API functions and then everything works. Obviously this fix would not work with linux but I do not know if the problem existed in linux.

    To get this code to work one must uncomment the following line from Tk::StayOnTop(version 0.12/line 58)

    return METHOD_ATTRIB if $Tk::VERSION >= 804.027;

    I will probably just implement the API calls that Tk::StayOnTop implements so then I can actually send this to others, but should I report this as a bug? and if so then what would this be a bug in?

    use Tk; require Tk::StayOnTop; require Tk::MatchEntry; $desc = ""; @opts = ("test","one","two","three"); $window = MainWindow->new; $window->Button(-text => "Button")->grid(-row=>1,-column=>0); $Entry = $window->MatchEntry(-textvariable => \$desc, -listcmd=>\&move +List)->grid(-row=>0,-column=>0); $Entry->choices(\@opts); $window->after(1000,sub {$window->stayOnTop()}); $window->bind('<FocusOut>', \&focusOut); MainLoop; sub moveList { if($lowered == 0) { $window->dontStayOnTop(); $lowered = 1; } } sub focusOut { if($lowered == 1) { $window->stayOnTop(); $lowered = 0; } }
      Send a bug to everyone :)
Re: Help preventing Tk::StayOnTop from hiding Tk::MatchEntry pop up list
by zentara (Cardinal) on Jul 01, 2009 at 18:21 UTC
    StayonTop is very cool, at my age the girl has to..... oops, back to Perl.

    Seriously, that feature is very platform_X_Windows_server dependent, and won't be reliable. Try to manually control your windows with timers, etc., to force the effect you want. Something have a $mw timer that raises itself every 10 millisecs, will probably keep a window positioned and on top.


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku