问题描述
我的 perl 代码如下所示:
#!/usr/bin/env perl
use strict;
use warnings;
use Tk;
my $mw = Tk::MainWindow->new();
$mw->overrideredirect(1);
my $canvas = $mw->Canvas(
-bg => 'white',-width => 410,)->pack(-fill => 'both',-expand => 1);
my $rect_filled = $canvas->createRectangle(
0,360,100,-outline => '#C0C0C0',-fill => '#FFEC73',);
$canvas->bind( $rect_filled,'<Enter>' => sub{
$canvas->itemconfigure( $rect_filled,-outline => '#E0E0E0',-fill => '#0000ff',);
});
$canvas->bind( $rect_filled,'<Leave>' => sub{
$canvas->itemconfigure( $rect_filled,);
});
$mw->MainLoop();
如果我运行此代码,我可以看到黄色矩形。但是,当我将鼠标从上方移入画布时,ENTER 事件仅在 ~30 像素后出现,如屏幕截图所示。
好像标题栏还在画布上方。
如何停止这种行为,以便也从坐标 (0,0) 引发 ENTER 事件?
-- 问题更新:
- Debian 8.11
- 侏儒 3.14.1
- Perl 5.20.2
- 传统知识 804.032
解决方法
我在阅读本文后找到了解决方法:
https://metacpan.org/pod/distribution/Tk/pod/Wm.pod#BUGS
return new GestureDetector(
onTap: () {
FocusScope.of(context).requestFocus(new FocusNode());
print('hey');
},child: Container(
color: Colors.white,child: TextField(
onChanged: (text) {},),);
但这是正确的方式吗?