Make ETable stop editing when it looses focus.

2001-01-27  Christopher James Lahey  <clahey@helixcode.com>

	* e-table-item.c (eti_event): Make ETable stop editing when it
	looses focus.

	* e-table.c (et_canvas_button_press): Make ETable stop editing if
	you click on an unhandled area of the table canvas (The white area
	at the bottom for instance.)

svn path=/trunk/; revision=7849
This commit is contained in:
Christopher James Lahey
2001-01-27 06:43:39 +00:00
committed by Chris Lahey
parent 803fc4da69
commit 133b44558c
2 changed files with 32 additions and 8 deletions

View File

@ -3,9 +3,10 @@
* E-table-item.c: A GnomeCanvasItem that is a view of an ETableModel.
*
* Author:
* Christopher James Lahey <clahey@ximian.com>
* Miguel de Icaza (miguel@gnu.org)
*
* Copyright 1999, Ximian, Inc.
* Copyright 1999, 2000, 2001, Ximian, Inc.
*
* TODO:
* Add a border to the thing, so that focusing works properly.
@ -1614,15 +1615,18 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
gtk_timeout_remove (eti->tooltip->timer);
eti->tooltip->timer = 0;
}
e_canvas_item_grab_focus(GNOME_CANVAS_ITEM(eti));
switch (e->button.button) {
case 1: /* Fall through. */
case 2:
e_canvas_item_grab_focus(GNOME_CANVAS_ITEM(eti));
gnome_canvas_item_w2i (item, &e->button.x, &e->button.y);
if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1))
if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1)) {
if (eti_editing (eti))
e_table_item_leave_edit (eti);
return TRUE;
}
ecell_view = eti->cell_views [col];
button = *(GdkEventButton *)e;
@ -1662,6 +1666,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
break;
case 3:
e_canvas_item_grab_focus(GNOME_CANVAS_ITEM(eti));
gnome_canvas_item_w2i (item, &e->button.x, &e->button.y);
if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1))
return TRUE;
@ -1965,6 +1970,12 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
eti->tooltip->timer = 0;
break;
case GDK_FOCUS_CHANGE:
if (! e->focus_change.in) {
if (eti_editing (eti))
e_table_item_leave_edit (eti);
}
default:
return_val = FALSE;
}

View File

@ -4,17 +4,14 @@
*
* Author:
* Miguel de Icaza (miguel@ximian.com)
* Chris Lahey (clahey@ximian.com)
* Chris Lahey <clahey@ximian.com>
*
* Copyright 1999, Ximian, Inc
* Copyright 1999, 2000, 2001, Ximian, Inc
*/
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#include <stdio.h>
#include "gal/util/e-i18n.h"
#include <libgnomeui/gnome-canvas.h>
@ -566,6 +563,18 @@ et_canvas_realize (GtkWidget *canvas, ETable *e_table)
NULL);
}
static void
et_canvas_button_press (GtkWidget *canvas, GdkEvent *event, ETable *e_table)
{
if (GTK_WIDGET_HAS_FOCUS(canvas)) {
GnomeCanvasItem *item = GNOME_CANVAS(canvas)->focused_item;
if (E_IS_TABLE_ITEM(item)) {
e_table_item_leave_edit(E_TABLE_ITEM(item));
}
}
}
static void
e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *header,
ETableModel *model)
@ -621,9 +630,13 @@ e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *h
"y2", (double) 100,
"fill_color_gdk", &GTK_WIDGET(e_table->table_canvas)->style->base[GTK_STATE_NORMAL],
NULL);
gtk_signal_connect (
GTK_OBJECT(e_table->table_canvas), "realize",
GTK_SIGNAL_FUNC(et_canvas_realize), e_table);
gtk_signal_connect (
GTK_OBJECT(e_table->table_canvas), "button_press_event",
GTK_SIGNAL_FUNC(et_canvas_button_press), e_table);
e_table->canvas_vbox = gnome_canvas_item_new(
gnome_canvas_root(e_table->table_canvas),
e_canvas_vbox_get_type(),