如何使用 Win32::GUI 重置 Perl 中的垂直滚动位置?
我正在使用 Win32::GUI 创建的文本字段输出一些内容,如下所示:
$Object->AddTextfield(
-name => "Birthchart",
-left => 75,
-top => 90,
-width => 250,
-height => 250,
-vscroll =>1,
-multiline => 1,
-prompt => "Birthchart",
);
{#do something here....
}
$Object->Birthchart->Append($Content);
问题是:它自动将我带到输出的末尾,但我想从头开始读取输出,而不必向上滚动。稍后再向下滚动就可以了。
我可以使用下面的代码
$Object->Birthchart->GetFirstVisibleLine();
来获取最上面可见行的行号,但是如何将最上面可见行的行号设置为0呢?
代码 $Object->Birthchart->ResetFirstVisibleLine() 不起作用。
有什么建议吗?提前致谢。
更新
尝试了以下代码
$Object->Birthchart->ScrollPos(1,0);
但仍然不起作用。滚动条似乎已重置,但我仍然必须单击滚动条才能查看文本字段内容的开头。
I'm outputting something to the textfield I created using Win32::GUI, like this:
$Object->AddTextfield(
-name => "Birthchart",
-left => 75,
-top => 90,
-width => 250,
-height => 250,
-vscroll =>1,
-multiline => 1,
-prompt => "Birthchart",
);
{#do something here....
}
$Object->Birthchart->Append($Content);
The problem is: it automatically takes me to the end of the output but I want to read the output from the beginning without having to scroll up. It's okay to scroll down later.
I can use the following code
$Object->Birthchart->GetFirstVisibleLine();
to obtain the number of the uppermost visible line, but how can I set the number of the uppermost visible line to 0?
The code $Object->Birthchart->ResetFirstVisibleLine() doesn't work.
Any suggestions? Thanks in advance.
Update
Tried the following code
$Object->Birthchart->ScrollPos(1,0);
But it still doesn't work. The scrollbar seems to be reset but I still have to click on the scrollbar to view the beginning of the textfield content.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决我的问题:
ScrollPos 似乎重置了滚动条位置但内容没有更新的原因是因为 ScrollPos() 只作用于滚动条。它不会更新文本字段的内容。
非常感谢 Anonymous Monk @perlmonks.org :) 原始答案位于此处。
The fix to my problem:
The reason why ScrollPos seems to have reset the scrollbar position but the content hasn't been updated is because ScrollPos() only acts on the scrollbar. It does not update the content of the textfield.
Many thanks to Anonymous Monk @perlmonks.org :) and the original answer is here.