2008/5/14 peter <gla...@ya...>:
> how can we enable the mouse right click on the Win32::GUI::RichEdit control,
> it is not enabled by default.
Yes it is {1]. (There is probably a better way of doing what you want [2].)
#!perl -w
use strict;
use warnings;
use Win32::GUI 1.05 qw(CW_USEDEFAULT);
my $mw = Win32::GUI::Window->new(
-title => 'RichEdit Right Click',
-left => CW_USEDEFAULT,
-size => [400,300],
);
my $re = $mw->AddRichEdit(
-width => $mw->ScaleWidth,
-height => $mw->ScaleHeight,
-onMouseRightUp => sub { print "Right Mouse Up!\n"; 1; },
);
$mw->Show();
Win32::GUI::Dialog();
$mw->Hide();
exit(0);
__END__
Regards,
Rob.
[1] OK, so an onRightClick event is not supported. The technical
difference is that onRightClick is only raised by controls that
generate a NM_CLICK notification, which RichEdit controls don't ever
raise. A RichEdit control will raise a WM_NOTIFY notification, of
type EN_MSGFILTER for a mouse right click, if the event mask for the
control includes ENM_MOUSEEVENTS. It could be considered a bug that
Win32::GUI does not set all this up and raise the onRightClick event
for RichEdit controls.
[2] If you want to get a right-click notification to display a context
menu, then it is better form to hook the WM_CONTEXTMENU message - this
is sent by the default message handlers if an unprocesssed right-click
is detected, or if the context-menu key (VK_APP, IIRC, to the right of
the space-bar) is pressed.
|