0

I have a Gtk.ColumnView where cells are represented by Gtk.EditableLabels. Keyboard navigation works fine, clicking in the cells to edit them works fine, tab navigation works fine.

However, clicking within a row to select that row doesn't work.

Some cells are editable (i.e. label.set_editable(True)) and some are not. The ones which are editable simply go into edit mode when clicked within the bounds of the label, the ones which are not don't react to clicks at all. In order to select a row with the mouse, I have to click in the "dead space" within the row, either between rows/cells or in a part of the cell that is not covered by a short label.

What I expect / want to happen, is for clicking on a non-editable cell to immediately select the row, and for clicking on an editable cell to select its row, and then begin editing.

I can sort of emulate this for non-editable rows by doing label.set_sensitive(False), but this styles everything with a light-grey "disabled" color, and that's not what I want to indicate; the row is interactable, it's just that that particular cell / column is not editable.

It seems in gtk4, there's no longer any "clicked" signal, so handling that is not possible; I gather I want to do something with a Gtk.Gesture event controller?


Update: while I haven't had time to fully isolate this example, there is open source code available here:

3
  • maybe create minimal working code so we could see what you created and to have code for tests. Commented Sep 16 at 19:00
  • sigh, I was really hoping someone would know the answer to this with just the description, but you're right, I should have made an executable example. I'll get to that soon. Commented Sep 18 at 2:49
  • I will try to minimize this at some point but for now I've linked to the example I was working on which brought it up Commented Sep 23 at 3:10

1 Answer 1

0

There are several ways, but I believe the simplest is to monitor the editing property of Gtk.EditableLabel and, whenever it changes from false to true, trigger an event that selects the row where the label is located.

I'm not sure how to select the row; I've never had to do it, but I think it's probably something done in Gtk.SelectionModel.

Sign up to request clarification or add additional context in comments.

1 Comment

So, this is indeed what I did, and it kinda works (you can see it here github.com/glyph/Pomodouroboros/blob/… ) but this has a bunch of drawbacks. The non-editable rows show as insensitive (i.e.: deactivated) which isn't the correct styling. The set_selected call (sometimes?) breaks the edit; it also doesn't work for odd edge-cases like if you've moved the selection some other way but click on an already-editing field. It just doesn't express what I want, which is "don't handle the click".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.