Re: GtkTreeView: how to get the cell with current focus?
- From: Reuben Rissler <silrep emypeople net>
- To: gtk-app-devel-list gnome org
- Subject: Re: GtkTreeView: how to get the cell with current focus?
- Date: Thu, 12 Jul 2018 15:01:44 -0400
I do this all the time in Python with:
def key_tree_tab(self, treeview, event):
keyname = Gdk.keyval_name(event.keyval)
path, col = treeview.get_cursor()
# only visible columns!!
columns = [c for c in treeview.get_columns() if c.get_visible()]
colnum = columns.index(col)
if keyname=="Tab" :
if colnum + 1 < len(columns):
next_column = columns[colnum + 1]
else:
tmodel = treeview.get_model()
titer = tmodel.iter_next(tmodel.get_iter(path))
if titer is None:
titer = tmodel.get_iter_first()
path = tmodel.get_path(titer)
next_column = columns[0]
GLib.timeout_add(10, treeview.set_cursor, path,
next_column, True)
Hope it helps!
On 07/12/2018 01:36 PM, Lars Paulsen wrote:
Hi All,
I did some further tests and the addresses returned in focus_column
are the same as the columns I created with
"gtk_tree_view_column_new();". Well, it's quite obvious but somehow I
expected that there is some API function which returns an index for a
column. Anyway, I will continue by comparing the addresses to find out
which column I am in. I need this to find out which column "is next".
I want to set the focus to the next cell/column if the user presses tab.
If anyone knows a better solution to determine the column/next column
please let me know.
Cheers,
Lars
Am 12.07.2018 um 18:11 schrieb Lars Paulsen:
Hello All,
I got a little problem with a GtkTreeView and with getting the cell
which actually has got the focus:
From the API documentation it seems like
gtk_tree_view_get_cursor(GTK_TREE_VIEW(tree), &path, &focus_column);
is doing the job. I can handle the path, it gives me the row which
has the focus. But how do I get the index of the cell from
focus_column (alias GtkTreeViewColumn)? A web search revealed some
old forum entries which seem to state that it is not supported.
Do I have to check the column name or compare the addresses of my
columns?
Thanks for any help in advance.
Best Regards,
Lars
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]