Hello Monks,

I’m new to the monetary so please forgive any unintentional broken rules.
I am working on a graphical interface that will be used to speed up data
retrieval from a remote server @ my workplace. My problem is not life or
death I’ve already got it working with a separate button, but I’d like to
be able to bind the delete button to delete unwanted entries from a scrolled
listbox, which I have working the only problem is I can’t get the right
widget to take focus on a button click. The current code makes the listbox
take focus but the button bind won’t work. However, if I tab from the entry
widget to the frame that contains the scolled widget the button bind works
flawlessly. Is there some way I can bind to <ButtonRelease-1> to focus on
the Tk::Frame that contains the widget?

System:

OS: HP-UX 10.2 and WinXP
PERL: build 5.0004 on HP and 5.8.8 on XP

# --------------------------------------
# ----- Parameter List and Delete Button
# --------------------------------------
$p2->Label( -width=>$testlbl,
-text=>"Parameter List",
-foreground=>'#FFFFFF',
-background=>'#666666',
-font=>$font,
-anchor=>'center')->
grid(-row => 6, -column => 0, -columnspan=>5, -padx=>5, -pady=>0, -sticky => 'ew');

$lstbox = $p2->Scrolled( "Listbox",
-scrollbars=>'osoe',
-selectmode=>'extended',
-foreground=>'#FFFFFF',
-background=>'#7E7E68',
-font=>$font,
-width=>40 )->
grid(-row => 7, -column =>0, -columnspan=>5, -padx=>5, -pady=>0, -sticky => 'nsew');

$lstbox->Subwidget("corner")->configure( -background=>'#666666' );
$lstbox->Subwidget("xscrollbar")->configure(-background=>'#666666' );
$lstbox->Subwidget("yscrollbar")->configure(-background=>'#666666' );
$lstbox->bind( '<ButtonRelease-1>' =>\sub{ $lstbox->focus});
$lstbox->bind($lstbox, '<Delete>' =>\&Deltxt );


In reply to Problem with Correct Widget focus(); by dakers001

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.