简体   繁体   English

如何在GTK +中找到给定方向的下一个小部件?

[英]How do I find the next widget in a given direction in GTK+?

I want to find out which widget is in a given direction in GTK+, ie doing what the "move-focus" signal does, but without actually changing the focus. 我想找出GTK +中给定方向上的哪个小部件,即执行“移动焦点”信号的操作,但实际上不更改焦点。 What I have in mind is a function that takes a GtkWidget * and a GtkDirectionType and returns the GtkWidget in the given direction (if any). 我想到的是一个函数,该函数接受GtkWidget *和GtkDirectionType并在给定方向(如果有)上返回GtkWidget。

What I want this for is to ultimately enumerate the widgets inside a specific GtkFrame in my UI definition, in order from left to right. 我想要的是最终在UI定义中按从左到右的顺序枚举特定GtkFrame中的小部件。 Ie basically create a list of widgets from leftmost to rightmost, inside my GtkFrame (or in the general case, inside any container). 即基本上在我的GtkFrame内(或通常情况下,在任何容器内)从最左到最右创建小部件列表。

I've tried to search the GTK documentation but haven't found anything that doesn't also change focus. 我曾尝试搜索GTK文档,但没有找到也不能改变重点的任何内容。

Failing any other approach, the way I'm going forward with is to copy a selected set of static functions from the library implementation of GtkContainer and put them in a file in my own application, modifying them to suit my needs. 如果没有其他方法,我将继续进行的方法是从GtkContainer的库实现中复制一组选定的静态函数,并将它们放在我自己的应用程序中的文件中,并对其进行修改以满足我的需要。

More specifically, the function gtk_container_focus_sort_left_right() and any local functions that it depends on. 更具体地说,函数gtk_container_focus_sort_left_right()及其依赖的任何局部函数。 This includes the GCompareFunc left_right_compare() and get_allocation_coords(). 这包括GCompareFunc left_right_compare()和get_allocation_coords()。

假设您关心的方向是“前进”和“后退”,这听起来像您想在框架上使用gtk_container_get_focus_chain() :它几乎完成了上面所说的:按焦点顺序获得小部件列表跳动时。

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

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