ch123 has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, My Scenario is : I created a frame with 4 to 5 label and entry widgets. I have 4 buttons in that frame. If I click one button named "Reset" , all the values in the entry widgets should be updated with some values and cursor should be placed in first entry widget. I AM FACING DIFFICULTY IN PLACING THE CURSOR IN FIRST ENTRY WIDGET. Can anyone help me how to do this ?? Waiting for reply, Regards, ch123

Replies are listed 'Best First'.
Re: How to change cursor position
by moritz (Cardinal) on Oct 08, 2009 at 09:34 UTC
    I assume you use a GUI toolkit - which one? What's your code?
    Perl 6 - links to (nearly) everything that is Perl 6.
      ya..u r correct.. I am using perl/Tk to develop GUI.... I cant share my code bcos of some legal issues. Can anybody provide me an example to change the cursor from one entry widget to other with in a frame... Any small help will be greatly appreciated..
        ya..u r correct.. I am using perl/Tk to develop GUI.... I cant share my code bcos of some legal issues. Can anybody provide me an example to change the cursor from one entry widget to other with in a frame... Any small help will be greatly appreciated.. I forgot to login before.... Regards, ch123
Re: How to change cursor position
by lamprecht (Friar) on Oct 08, 2009 at 13:03 UTC
    Hi,

    you want focus(). Here is an example:

    use strict; use warnings; use Tk; my $mw = tkinit; my @e = map {$mw->Entry->pack} (0..4); my $b = $mw->Button(-text => 'clear', -command => sub{for (@e){$_->delete(0,'end')} $e[0]->focus; })->pack; MainLoop;

    Cheers, Christoph