AdaCore / AdaCore/gtkada

Canvas_View: limiting drag of items is not working

Open
#53 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ada
Stars
110
Forks
22
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at gtkada-canvas_pkg.adb line 509 and reproduce the On_Item_Event_Move_Item example with Event.Allowed_Drag_Area set to Some_Rectangle. Check the drag behavior with the current handler and confirm that items remain within the specified rectangle when the issue is fixed.

Written by the indexing model from the issue text.

Assessment

Domain
desktop
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.