SPEventContext stops receiving button1 press/release events
Hello,
I don't really understand what I am doing wrong. I have a button on the toolbar of the connector tool (InkAction) that, when gets pressed, basically creates a new knot that follows the mouse pointer.
At this point (after the button is pressed) SPEventContext (for the connector tool) stops receiving any button1 press/release events. Other buttons press/release, pointer motion events are received.
I don't even have a clue for where to start debugging, please help.
Thank you.
Following are some code exerpts:
from toolbox.cpp: =========== ... g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_connector_new_connection_point), holder ); ... static void sp_connector_new_connection_point(GtkWidget *widget, GObject *tbl) { SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); SPConnectorContext* cc = SP_CONNECTOR_CONTEXT(desktop->event_context);
if (cc->mode == SP_CONNECTOR_CONTEXT_EDITING_MODE) cc_create_connection_point(cc); std::cout<<"Done new connection point."<<std::endl; } ...
from connector-context.cpp ================== ... void cc_create_connection_point(SPConnectorContext* cc) { if (cc->active_shape && cc->state == SP_CONNECTOR_CONTEXT_IDLE) { if (cc->selected_handle) { cc_deselect_handle( cc->selected_handle ); } SPKnot *knot = sp_knot_new(cc->desktop, 0); cc_select_handle( knot ); cc->selected_handle = knot; cc->state = SP_CONNECTOR_CONTEXT_NEWCONNPOINT; } } ...
Regards, Arcadie Cracan
Arcadie M. Cracan wrote:
I don't really understand what I am doing wrong. I have a button on the toolbar of the connector tool (InkAction) that, when gets pressed, basically creates a new knot that follows the mouse pointer.
At this point (after the button is pressed) SPEventContext (for the connector tool) stops receiving any button1 press/release events. Other buttons press/release, pointer motion events are received.
That's because those events are processed by the knot. It would be impossible to write anything if you also received those events on the context. Instead of button 1 events on the context, you get emissions of the "clicked", "grabbed", "request" and "ungrabbed" signals on the knot. If that's not what you want, use the canvas item used for knots directly (but keep in mind that users will expect it to behave like other knots).
Too bad you already wrote some code using the old SPKnot class, because as part of my GSoC work I wrote a C++ class for a control point that has more features and is easier to use (for example, it uses libsigc++ signals).
Regards, Krzysztof
OK, maybe disregard the part about my knot class. It's similar to the current one, so it will be easy to port from SPKnot should you wish to do it. Good luck with finishing the project :)
Regards, Krzysztof
Actually, you were right!
I wasn't too attentive :). That knot was actually created without disconnecting it's default event processing function.
Thanks a lot.
Regards, Arcadie
Krzysztof Kosiński wrote:
Arcadie M. Cracan wrote:
I don't really understand what I am doing wrong. I have a button on the toolbar of the connector tool (InkAction) that, when gets pressed, basically creates a new knot that follows the mouse pointer.
At this point (after the button is pressed) SPEventContext (for the connector tool) stops receiving any button1 press/release events. Other buttons press/release, pointer motion events are received.
That's because those events are processed by the knot. It would be impossible to write anything if you also received those events on the context. Instead of button 1 events on the context, you get emissions of the "clicked", "grabbed", "request" and "ungrabbed" signals on the knot.
Well, my thought was the same, that events get processed by the knot. The events for the knots are processed by the function cc_generic_knot_handler. Here are some more excerpts from my tentatives to find the bug: - the way knots are created: ... SPKnot *knot = sp_knot_new(desktop, 0); ... // We don't want to use the standard knot handler.
g_signal_handler_disconnect(G_OBJECT(knot->item), knot->_event_handler_id); knot->_event_handler_id = 0;
gtk_signal_connect(GTK_OBJECT(knot->item), "event", GTK_SIGNAL_FUNC(cc_generic_knot_handler), knot); ...
- an excerpt from cc_generic_knot_handler: ... if (event->type == GDK_BUTTON_PRESS) std::cout<<"generic_knot_handler: A button has been pressed."<<std::endl; ...
I have similar messages in all functions that process events (root_handler, item_handler) and I never see a message when I click button1. That's what bugs me most :), I can't figure out where these events are "lost".
Too bad you already wrote some code using the old SPKnot class, because as part of my GSoC work I wrote a C++ class for a control point that has more features and is easier to use (for example, it uses libsigc++ signals).
I guess there are more improvements that you already made that I could use for the connector tool (I'm intending to make use of the node tool for editing connection points), but I will look to them after GSoC.
Thank you for the reply.
Regards, Arcadie
participants (2)
-
Arcadie M. Cracan
-
Krzysztof Kosiński