Re: Get mouse clicks on the map



2010/1/9 Emmanuel Rodriguez <emmanuel rodriguez gmail com>
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),
      NULL);

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);

I can confirm that the callback in the launcher demo from git master doesn't seem to get called.

Keith.


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