gpt4 book ai didi

gtk - 如何在 GtkEntry 中捕获 Enter 按键

转载 作者:行者123 更新时间:2023-12-03 23:46:32 27 4
gpt4 key购买 nike

我试图在 GtkEntry 中按下 Enter 键时捕获它.我发现的大多数资源都建议连接到 activate信号,但 documentation for GtkEntry状态(强调我的):

Applications should not connect to it, but may emit it with g_signal_emit_by_name() if they need to control activation programmatically.



我很好奇这背后的基本原理以及普遍接受的替代方案是什么。我知道我可以连接到 key-press-event发出信号并检查关键代码,但我想知道是否有更优雅的解决方案。

最佳答案

提到的激活信号的 GtkEntry 文档:

Applications should not connect to it, but may emit it with g_signal_emit_by_name() if they need to control activation programmatically.



...已更改为:

While this signal is used as a keybinding signal, it is also commonly used by applications to intercept activation of entries.



这发生在 2012 年 6 月 11 日,提交 4a25bac0e7685000fff90a211db6ac60f6b74ab1 .提交消息是:

Update docs for GtkEntry::activate

Remove the 'you shall not connect' message from this signal. While it is a keybinding signal, using it from applications is fine and, in fact, expected.

关于gtk - 如何在 GtkEntry 中捕获 Enter 按键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8520538/

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