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; } }

In reply to Re: Help preventing Tk::StayOnTop from hiding Tk::MatchEntry pop up list by imbeyondboredom
in thread Help preventing Tk::StayOnTop from hiding Tk::MatchEntry pop up list by imbeyondboredom

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.