简体   繁体   English

如何在Gtk#Notebook小部件中处理选项卡选择?

[英]How to handle tab selection in Gtk# Notebook widget?

I thought it will be easy, but... 我觉得这很容易,但......

// An empty Notebook defined in Stetic designer and created in generated code
Notebook tabs = this.TabsContainer;

tabs.SelectPage += (o, args) => {
    Application.Quit();
};

// Then I add some pages in code by calling tabs.AppendPage(...)

With this code, when I switch Notebook pages back and forth by clicking at tabs, event is obviously not handled. 使用此代码,当我通过单击选项卡来回切换Notebook页面时,事件显然不会被处理。 I tried also using other event ( FocusTab ), but handler is never called anyway. 我也试过使用其他事件( FocusTab ),但是从不调用处理程序。 What have I missed? 我错过了什么?

I looked at the sources of gtk+ and it seems that the select-page signal is defined, but is never emitted (I will probably file a bug to mark it as deprecated). 我查看了gtk +的来源,似乎定义了select-page信号,但是从未发出(我可能会提交一个bug来将其标记为已弃用)。

I also noticed that the signal switch-page (which you should be able to subscribe via the event SwitchPage ) is certainly emitted, so this should work (please report back if it doesn't and I'll take another look). 我还注意到信号切换页面(你应该能够通过事件SwitchPage订阅)肯定会被发出,所以这应该工作(请报告回来,如果没有,我会再看看)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM