Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    FormItem Drag and Drop

    Hi,
    Currently none of the FormItem's support a Drop Handler. This means we can not drop a record onto a form item(textitem, or anything else within a dynamic) form.

    Are there any plans to support this in future?

    Thanks
    Ganesh

    #2
    Add a drop handler at the form level.

    Comment


      #3
      Hi,

      Does it remain impossible to drop things in a certain FormItem ?

      Scenario:
      a tabset where each tab represents an object.
      Object 1 can link to Object 2 by means of a FormItem.
      So the user should be able to drag Tab 1, go over the header of Tab 2 which then becomes active, and drop the Tab 1 into a certain FormItem.

      Form 2 can have none, 1 or more than 1 FormItem which accepts types of Object 1, so the user cannot just drop the Object 1 on the Form, which would trigger some code to put it in the correct FormItem.

      + the user should visually see if the destination FormItem accepts his drag object.

      Comment


        #4
        All possible via drop handlers on the DynamicForm, but obviously requires some effort to figure out coordinates of FormItems to see which is the target.

        As you can see in Visual Builder, we've implemented such a system in a purpose-specific way, but it's not documented yet and lacks enough override points for external usage. If you'd like to use this system, consider Feature Sponsorship.

        Comment


          #5
          This is an old topic, but I have the same problem. I need to determine which form item received drop event.
          This is how I am doing it:
          1) I add DropHandler to DynamicForm
          2) On DropEvent I am determining mouse coordinates
          3) Then I am cycling hrough form's items and determining if mouse is within their coordinates.

          Code:
          @Override
          public void onDrop(DropEvent event) {
          	int mouseX = EventHandler.getX() - form.getAbsoluteLeft();
          	int mouseY = EventHandler.getY() - form.getAbsoluteTop();
          	
          	for (FormItem formItem : form.getFields()) {
          		if (!(formItem instanceof SectionItem)) {
          			int itemX = formItem.getLeft();
          			int itemY = formItem.getTop();
          			int itemX2 = itemX + formItem.getWidth();
          			int itemY2 = itemY + formItem.getHeight();
          
          			if (mouseX >= itemX && mouseX <= itemX2 && mouseY >= itemY && mouseY <= itemY2) {
          				// This is the item i've been looking for
          			}
          		}           
          	}
          }
          It's working perfectly with numCols = 2 (when all the fields are in one column). But it does not work if I set numCols = 4 or more. Form items that are not on first column still think their coordinates are on the first column.
          I am stuck, Isomorphic - can you drop a little hint how can I determine which form item mouse is released on?

          Comment


            #6
            Never-mind, it works perfectly. I had some errors on creating forms items. Ony checkbox items need some custom code,

            Comment

            Working...
            X