AdaCore / gtkada

Ada bindings for the GTK+ graphical library.
Other
88 stars 19 forks source link

Canvas_View: limiting drag of items is not working #53

Open fdesp87 opened 1 year ago

fdesp87 commented 1 year ago

As an example, if the program defines the handler for item movement as:

   function On_Item_Event_Move_Item
        (View   : not null access Glib.Object.GObject_Record'Class;
         Event : Event_Details_Access)
      return Boolean
   is
   begin
      Event.Allowed_Drag_Area := Some_Rectangle;
      return Gtkada.Canvas_View.Views.On_Item_Event_Move_Item (View, Event);
   end On_Item_Event_Move_Item;

and then the handlers:

 Canvas.On_Item_Event (On_Item_Event_Select'Access);
 Canvas.On_Item_Event (On_Item_Event_Move_Item'Access);

However, dragging is not limited in any way.

Diving into the problem, I commented out gtkada-canvas_pkg.adb line 509:

  .....

  then
     --  Enable moving the item anywhere
     --  ===> JLF 2023-10-03 Event.Allowed_Drag_Area := Drag_Anywhere; <===
     Self.Model.Raise_Item (Event.Toplevel_Item);
     return True;
  end if;
  return False;

end On_Item_Event_Move_Item;

and voilá, dragging is now limited to the rectangle.