gpt4 book ai didi

Perl Gtk3::ScrolledWindow 包含多个 Gtk3::TreeView child。选择一行时如何禁止 child 滚动到顶部?

转载 作者:行者123 更新时间:2023-12-04 15:19:57 26 4
gpt4 key购买 nike

我正在使用 Gtk3 在 Perl 中编写程序。我有一个包含多个 TreeView 的左侧边栏(不使用任何侧边栏小部件)。

我是这样设置的:

my $sidebarscrollarea = Gtk3::ScrolledWindow->new( undef, undef );

my $sidebarlabelaccounts = Gtk3::Label->new("Accounts");
$sidebarlabelaccounts->set_halign('GTK_ALIGN_START');
my $sidebarlabelincome = Gtk3::Label->new("Income Envelopes");
$sidebarlabelincome->set_halign('GTK_ALIGN_START');
my $sidebarlabelexpense = Gtk3::Label->new("Expense Envelopes");
$sidebarlabelexpense->set_halign('GTK_ALIGN_START');

# *_create_model() builds the models
my $account_tstore = account_create_model();
my $income_tstore = envelope_create_model();
my $expense_tstore = envelope_create_model();

# populate the models with another subroutine
populate_models();

my $accountslist = Gtk3::TreeView->new();
$accountslist->set_model($account_tstore);
my $incomelist = Gtk3::TreeView->new();
$incomelist->set_model($income_tstore);
my $expenselist = Gtk3::TreeView->new();
$expenselist->set_model($expense_lstore);

# Add columns to model and view via view ( Gtk3::TreeView )
account_add_columns($accountslist);
envelope_add_columns($incomelist);
envelope_add_columns($expenselist);

my $sidebarbox = Gtk3::Box->new('vertical',1);
$sidebarbox->set_border_width(5);
$sidebarbox->pack_start($sidebarlabelaccounts,0,0,5);
$sidebarbox->pack_start($accountslist,0,6,5);
$sidebarbox->pack_start($sidebarlabelincome,0,0,5);
$sidebarbox->pack_start($incomelist,0,6,0);
$sidebarbox->pack_start($sidebarlabelexpense,0,0,5);
$sidebarbox->pack_start($expenselist,0,6,0);

$sidebarscrollarea->add($sidebarbox);

信封列表很长。当我单击该列表中靠近窗口底部的一行时,它会滚动,以便在窗口顶部列出信封。无论我在哪里单击一行,我都不希望它移动到任何地方。谢谢你的帮助。我对这一切都是陌生的。

最佳答案

简单地添加:

$expenselist->set_can_focus(FALSE);

解决了我的问题。

关于Perl Gtk3::ScrolledWindow 包含多个 Gtk3::TreeView child。选择一行时如何禁止 child 滚动到顶部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63538052/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com