Re: GtkSheet works on Gtk2.2 ?



On Tuesday 28 October 2003 16:08, Lorenzo Gil Sanchez wrote:

Hi Lorenzo,

I also need a sheet like widget and I have adapted a GtkTreeView to do
almost what I want. But there is a feature I can't make it work. In a
sheet widget like the one Gnumeric/Excel/Access uses the user can freely
move through the cells pretty fast. In an editable GtkTreeView the user
need to press enter to make a cell editable, then edit it, then press
enter (or tab or an arrow key) again, and then move to the next cell. If
he/she need to enter a lot of information I think the GtkTreeView is not
a solution. In Gnumeric, in the other way, a user edits the information
directly because all the cells are in 'editable' mode by default and
then if he/she press tab/up arrow/down arrow he/she moves to another
cell, which can be edited right now.

Isn't it possible to connect to the 'cursor-changed' signal and automatically 
put the cell the cursor went to into editing mode with 
gtk_tree_view_set_cursor() etc.?


I guess the problem is in the design of the GtkCellRenderer or the
GtkCellEditable interface because once a cell enters in editable mode
the owner of that cell (the GtkTreeView in this case) can't access the
key that the user pressed to focus out the cell and thus, leave the
editable mode. That's why the GtkTreeView doesn't know where to go when
the user press tab after editing a cell, it just know that the cell is
not in the editable state anymore.

You could write your own cell renderer that derives from GtkCellRendererText, 
and copy'n'paste the 2-3 functions of GtkCellRendererText that start/stop the 
editing, and customise those functions to your needs (e.g. connect a key 
press event handler to the entry widget etc.). 

Maybe this isn't even necessary, and you could just connect a 
'key-press-event' handler to the main window or tree view, in which case you 
would get the key press events before the entry widget does, and could pass 
on the events or not as you please, and take the appropriate action (e..g 
move down one cell, etc.).

Just some ideas, I have no idea if they work :)

Cheers
-Tim




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]