Re: Get mouse clicks on the map

On Sat, Jan 9, 2010 at 11:32 AM, Emmanuel Rodriguez <emmanuel rodriguez gmail com> wrote:
On Sat, Jan 9, 2010 at 11:06 AM, Keith Sharp <keith sharp gmail com> wrote:
I've been tinkering with the launcher-gtk.c program in the demos, and I was trying to add the abilty to catch mouse clicks on the map and print them to the console (with the ultimate aim of creating a marker or popup menu on a mouse click).
The demo laucher.c shows how to do it. You first have to set the view as 'reactive' with clutter_actor_set_reactive().

  clutter_actor_set_reactive (actor, TRUE);
  g_signal_connect (actor, "button-release-event",

      G_CALLBACK (mouse_click_cb),

The rest of the code should be the same as you wrote it.

Note: I think that version 0.4.3 has a regression because the callback doesn't seem to be called. I will wait a bit until Pierre-Luc confirms this.

I can confirm that there's a bug. If the ChamplainLayer is not added then the view receives the events. In the case where the layer is added and the mouse event is added to the layer then the layer will receive the mouse events only if the zoom level is above 13.

// Click events are sent to the layer only if zoom-level >= 13
  layer = create_marker_layer (view);
  clutter_actor_set_reactive (CLUTTER_ACTOR (layer), TRUE);
  g_signal_connect (layer, "button-release-event",
        G_CALLBACK (map_view_button_release_cb), view);

Emmanuel Rodriguez

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