You typically only need to put the tag in the binding if it refers to a window. Basically, just removing the $lstbox tag from the bind to <Delete> command makes it work.

BTW, it is usually better if you can provide a complete runable script when you ask a question. A lot of times, if there isn't a framework to run your code, your question will get fewer responses.

I built a small demo script using your posted code. Try this.

Update: Whoops, didn't notice extended select mode. Changed Deltxt sub appropriately.

use strict; use warnings; use Tk; my $testlbl = 15; my $font = '{New Times Roman} 12'; my $p2 = MainWindow->new; $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' ); my $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( '<Delete>' => \&Deltxt ); $lstbox->insert( 'end', $_ ) for ( 1 .. 20 ); MainLoop; sub Deltxt { return unless my @indicies = $lstbox->curselection; $lstbox->delete( $_ ) for @indicies; }

In reply to Re: Problem with Correct Widget focus(); by thundergnat
in thread 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.