From f6c2660540212355133d68b1e8e72c2bcd1fdec5 Mon Sep 17 00:00:00 2001 From: cilix42 Date: Fri, 5 Sep 2008 18:54:49 +0000 Subject: [PATCH] Make click-select work in geometry tool --- src/lpe-tool-context.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp index 9b0a8380b..ec4cd0689 100644 --- a/src/lpe-tool-context.cpp +++ b/src/lpe-tool-context.cpp @@ -46,6 +46,7 @@ static void sp_lpetool_context_dispose(GObject *object); static void sp_lpetool_context_setup(SPEventContext *ec); static void sp_lpetool_context_set(SPEventContext *ec, gchar const *key, gchar const *val); +static gint sp_lpetool_context_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event); static gint sp_lpetool_context_root_handler(SPEventContext *ec, GdkEvent *event); void sp_lpetool_context_selection_changed(Inkscape::Selection *selection, gpointer data); @@ -99,6 +100,7 @@ sp_lpetool_context_class_init(SPLPEToolContextClass *klass) event_context_class->setup = sp_lpetool_context_setup; event_context_class->set = sp_lpetool_context_set; event_context_class->root_handler = sp_lpetool_context_root_handler; + event_context_class->item_handler = sp_lpetool_context_item_handler; } static void @@ -211,6 +213,37 @@ sp_lpetool_context_set(SPEventContext *ec, gchar const *key, gchar const *val) **/ } +static gint +sp_lpetool_context_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event) +{ + gint ret = FALSE; + + switch (event->type) { + case GDK_BUTTON_PRESS: + { + // select the clicked item but do nothing else + Inkscape::Selection * const selection = sp_desktop_selection(ec->desktop); + selection->clear(); + selection->add(item); + ret = TRUE; + break; + } + case GDK_BUTTON_RELEASE: + // TODO: do we need to catch this or can we pass it on to the parent handler? + ret = TRUE; + break; + default: + break; + } + + if (!ret) { + if (((SPEventContextClass *) lpetool_parent_class)->item_handler) + ret = ((SPEventContextClass *) lpetool_parent_class)->item_handler(ec, item, event); + } + + return ret; +} + gint sp_lpetool_context_root_handler(SPEventContext *event_context, GdkEvent *event) { -- 2.30.2