Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^10: Getting selection from Tkx text (typos)

by Anonymous Monk
on Apr 05, 2013 at 08:03 UTC ( [id://1027094]=note: print w/replies, xml ) Need Help??


in reply to Re^9: Getting selection from Tkx text (typos)
in thread Getting selection from Tkx text

Sorry the command should have read

Um, thats not the only typo. No matter, here is some working code

#!/usr/bin/perl -- ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr +-ce -nibc -i=4 -pt=0 "-nsak=*" use strict; use warnings; use Data::Dump qw/ dd pp/; $Tkx::TRACE = 64; use Tkx; use Tkx::FindBar; my $name; my $mw = Tkx::widget->new( '.' ); my $text = $mw->new_text( -width => 20, -height => 10, ); foreach( qw/David Mary William/ ) { $text->insert( 'end', "$_\n" ); } my $findbar = $mw->new_tkx_FindBar( -textwidget => $text, ); $mw->g_bind( '<Control-f>' => [ \&Tkx::FindBar::show, $findbar ], +); $mw->g_bind( '<F3>' => [ \&Tkx::FindBar::next, $findbar ], +); $mw->g_bind( '<Shift-F3>' => [ \&Tkx::FindBar::previous, $findbar ], +); $mw->g_bind( '<Return>', \&fudge, ); $findbar->g_pack(); $text->g_pack(); $findbar->show(); Tkx::MainLoop(); sub fudge { dd( \@_ ); dd [ $text->m_tag_configure( 'highlight' ) ]; $name = $text->get( qw/highlight.first highlight.last/ ); print "The name is $name\n"; dd [ $text->tag( qw' ranges highlight' ) ]; $text->m_tag_add( 'sel', qw/highlight.first highlight.last/ ); $text->g_focus; ## g_focus is g_focus not m_focus $findbar->hide; } ## end sub fudge

Replies are listed 'Best First'.
Re^11: Getting selection from Tkx text (typos)
by dabella12 (Acolyte) on Apr 09, 2013 at 20:48 UTC

    Thank you that works perfectly

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1027094]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-03-29 10:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found