Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Cursor keys with Tk::Hlist goes wrong

by luke67m (Initiate)
on Aug 28, 2014 at 16:45 UTC ( #1098885=perlquestion: print w/ replies, xml ) Need Help??
luke67m has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks. I'm trying to use Tk::Hlist in a panel for file selection. I'm trying to make the panel usable both under linux and windows. I'm a newby. The hlist has 3 Columns. Here the problem : Under linux, if I define the first column with itemCreate, the cursor keys up and down works in unpredictable ways : Up sometimes goes down and down sometimes goes up. Under windows everything seems to work. Here a sample of my code
########################################################### #this not work my $e = $tree->add( $dir ); $tree->itemCreate ($e, 0, -itemtype => 'imagetext', -text => $text, -image => $tree->Getimage("folder"), -style=> $Col0StyleA ); #this not work ########################################################### #this work # my $e = $tree->add( $dir , -text => $text, -image => $tree->Geti +mage("folder"), # ); #this work ###########################################################
I'm using winxp strawberry 5.18 and lubuntu 14.4 . Feel free to ask for full source, I can publish it on sourceforge

Comment on Cursor keys with Tk::Hlist goes wrong
Download Code
Re: Cursor keys with Tk::Hlist goes wrong
by zentara (Archbishop) on Aug 28, 2014 at 18:55 UTC
    I don't know why your bindings have messed up, but maybe you can manually fix them. Add corrections yourself. I'm hazarding a guess that you have your indices all messed up, and don't realize it. Here is a clue as to how to do it.
    #!/usr/bin/perl use warnings; use strict; use Tk; my $mw = tkinit; my $hl = $mw->HList(-itemtype=>'text')->pack; for my $n (0..5){ $hl->add($n , -text=>"Item $n", ); } $mw->bind('<Key-F1>',sub{$hl->selectionClear; $hl->anchorClear; $hl->selectionSet(0); $hl->anchorSet(0); } ); MainLoop; # by Christoph

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      I have tried your suggestion but it does not solve the problem. I've binded the function to F3. After the problem appears , I press F3, the selection is repositioned at root(my 0 Is \) but, after this , the problem persist : pressing 5 up_key the cursor goes up 3 Times and down 2 Times(really strange...).
        You can find all the code (with your suggestion) at https://sourceforge.net/projects/copyandverify/files/ver0.010_ReplByDate/ . At the moment, the linux version has the itemcreate for col 0 commented and the add (with all attributes) active, so it works. If you search a line with all # you find the problematic code and your suggestion (on F3).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1098885]
Approved by AppleFritter
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (11)
As of 2014-10-22 21:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (122 votes), past polls