Greg,

I'm not sure if this is exactly what you're looking for (the KeyDown bit
confused me), but if you replace the event declaration in your example from

sub LV_ReturnPressed {

to

sub LV_ReturnPressed_Click {

then you get the "Return Pressed" message.

Glenn 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Greg
Osborne
Sent: Friday, 12 August, 2005 18:25
To: perl-win32-gui-users@lists.sourceforge.net
Subject: [perl-win32-gui-users] Listview/interaction

I am having some trouble figuring out how to capture an enter/return event
in a listview and treat it like a click event.  I have noticed the KeyDown
event, and figure that is what I'd need to use to capture the backspace and
delete keys, but am not sure where to gather the values to capture these
keystrokes.  It seems as if the return and other keys are triggering the
KeyDown event and over-ride the accelerator table, but values such as 10 and
13 which are normal dos keyboard values for return/control return aren't
being seen with KeyDown.

Code below shows some of what I've tried.


use Win32::GUI;

$Accelerator = new Win32::GUI::AcceleratorTable( "Return" =>
"LV_ReturnPressed"
);

$Window = new Win32::GUI::DialogBox(
-name => Window,
-text => "Test ListView Window",
-accel => $Accelerator,
-height => 500,
-width => 500,
-top => 0,
-left => 0,
-minimizebox => 1,
-maximizebox => 1,
-resizable => 1
);

$LV = $Window->AddListView(
-name => LV,
-text => "Test ListView",
-left => 0,
-top => 0,
-height => 500,
-width => 500,
-list => 1,
#-hottrack => 1, -- wasn't sure if this made a difference -tabstop => 1, );

$LV->Add(
{-text => "First"},
{-text => "Second"},
{-text => "Third"}
);

$LV->InsertColumn(
-height => 500,
-width => 500,
-index => 0
);

$LV->SetFocus();
$Window->Show();
Win32::GUI::Dialog();

sub Window_Terminate { return -1; }

sub Window_Activate { $LV->SetFocus(); }

sub LV_Click {
$Item = $LV->GetSelectionMark();
print "\aClicked on $Item\n";
}

sub LV_DoubleClick {
$Item = $LV->GetSelectionMark();
print "\aDouble Click on $Item\n";
}

sub LV_KeyDown {
$Key = shift;

print "$Key pressed.\n";
}


sub LV_ReturnPressed {
print "\aReturn pressed.\n";
}


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September
19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile &
Plan-Driven Development * Managing Projects & Teams * Testing & QA Security
* Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
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