Daniel,

When I read this, I thought that the problem would be a missing -dialogui
option, but then I saw you had that. After that, I removed the "hack" code
and it still worked--am I missing the point? On my system, you can tab
between textfields using the following code:


use Win32::GUI;

my $window = Win32::GUI::Window 
    -> new (
            -name => 'window',
            -text => "Window",
            -width => 300,
            -height => 200,
            -dialogui => 1,
            );

$t1 = $window
    -> AddTextfield (-name => 't1',
                     -left => 30,
                     -top => 50,
                     -width => 100,
                     -height => 22,
                     -tabstop => 1,
                     -prompt => ["Text 1",50],
                     );

$t2 = $window
    -> AddTextfield (-name => 't2',
                     -left => 30,
                     -top => 100,
                     -width => 100,
                     -height => 22,
                     -tabstop => 1,
                     -prompt => ["Text 2",50],
                     );

$t1 -> SetFocus();
$window -> Show();

sub window_Terminate { -1 }

Win32::GUI::Dialog();


>>>>>>>>>>>>>>>>>>>>>>>>

Glenn 


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Daniel Jordan
Sent: Tuesday, August 10, 2004 04:49
To: perl-win32-gui-users@lists.sourceforge.net
Subject: [perl-win32-gui-users] Tab between controls in a Window using an
Accelerator table

I wasn't able to find any solutions to this in the archives, but I was able
to hack my way through it and thought I'd share.  

The problem I was having was to use Tab to move between fields in a window
(I usually use a DialogBox, but wanted a scroll bar - thanks to kenneth for
his great example of doing that).  

I came up with the following (no scroll bars here), but I feel like it's a
hack and there should be a better way to do it.  But nothing else seemed to
work.
 So if anyone has a more elegant solution, please let me know.


use Win32::GUI;


$AccTable = new Win32::GUI::AcceleratorTable(
                                      "Ctrl-X" => "Close",
                                      "Tab" => "Tab",
                                      "Shift-Tab" => "Shift_Tab",
                                      );

my $window = Win32::GUI::Window 
    -> new (
            -name => 'window',
            -text => "Window",
            -width => 300,
            -height => 200,
            -dialogui => 1,
            -accel => $AccTable,
            );

$t1 = $window
    -> AddTextfield (-name => 't1',
                     -left => 30,
                     -top => 50,
                     -width => 100,
                     -height => 22,
                     -tabstop => 1,
                     -prompt => ["Text 1",50],
                     );

$t2 = $window
    -> AddTextfield (-name => 't2',
                     -left => 30,
                     -top => 100,
                     -width => 100,
                     -height => 22,
                     -tabstop => 1,
                     -prompt => ["Text 2",50],
                     );

my @focuslist = ("t1","t2");

sub Close_Click {
    print "x\n";
    $window -> Hide();
    return -1;
}

sub Tab_Click {
    my $focusat;
     for (my $i=0;$i<=$#focuslist;$i++) {
        if (Win32::GUI::GetFocus() == $window -> {$focuslist[$i]} ->
{-handle}) {
            if ($i < $#focuslist) {
                $focusat = $i+1;
            } else {
                $focusat = 0;
            }
        }
     }
    $window -> {$focuslist[$focusat]} -> SetFocus(); }

sub Shift_Tab_Click {
    my $focusat;
     for (my $i=0;$i<=$#focuslist;$i++) {
        if (Win32::GUI::GetFocus() == $window -> {$focuslist[$i]} ->
{-handle}) {
            if ($i >0) {
                $focusat = $i-1;
            } else {
                $focusat = $#focuslist;
            }
        }
     }
    $window -> {$focuslist[$focusat]} -> SetFocus(); }



$t1 -> SetFocus();


$window -> Show();

sub window_Terminate { -1 }

Win32::GUI::Dialog();







                
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail


-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk
Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off
Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users


Reply via email to