One suggestion as I suspect this was unintended.
When dragging form low index to higher index the dropped index was (dest 
-1) and for me should be dest idx.

                    if(destIndex > i) {
                        t.insertTab(title, null, source, destIndex - 1);
                    } else {
                        t.insertTab(title, null, source, destIndex);
                    }

                   should become:
                  t.insertTab(title, null, source, destIndex);

Q. How can we change the drag sensitivity or delay so that when I want to 
scroll my tab list the dragged listener does not interpret this as a drag 
request.

Thanks in advance.

Regards




On Tuesday, May 7, 2019 at 8:59:05 AM UTC-4, [email protected] wrote:
>
> Thanks so much.
> That worked perfectly
>
> Regards
>
> On Monday, May 6, 2019 at 11:08:42 PM UTC-4, Shai Almog wrote:
>
>> I thought this would make an interesting blog post so I wrote a full 
>> working sample. My initial mock had a mistake in listener registration:
>>
>> Form hi = new Form("Tabs", new BorderLayout());
>>
>> Tabs t = new Tabs();
>>
>> t.addTab("T1", new Label("Tab 1"));
>> t.addTab("T2", new Label("Tab 2"));
>> t.addTab("T3", new Label("Tab 3"));
>> t.addTab("T4", new Label("Tab 4"));
>>
>> Container tabsC = t.getTabsContainer();
>> tabsC.setDropTarget(true);
>> for(Component c : tabsC) {
>>     c.setDraggable(true);
>>     c.addDropListener(e -> {
>>         e.consume();
>>         Component dragged = c;
>>         int x = e.getX();
>>         int y = e.getY();
>>         int i = tabsC.getComponentIndex(dragged);
>>         if(i > -1) {
>>             Component dest = tabsC.getComponentAt(x, y);
>>             if(dest != dragged) {
>>                 Component source = t.getTabComponentAt(i);
>>                 int destIndex = tabsC.getComponentIndex(dest);
>>                 if(destIndex > -1 && destIndex != i) {
>>                     String title = t.getTabTitle(i);
>>                     t.removeTabAt(i);
>>                     if(destIndex > i) {
>>                         t.insertTab(title, null, source, destIndex - 1);
>>                     } else {
>>                         t.insertTab(title, null, source, destIndex);
>>                     }
>>                 }
>>             }
>>             tabsC.animateLayout(400);
>>         } 
>>     });
>> }
>>
>> hi.add(CENTER, t);
>> hi.show();
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/41d87b53-3e4f-46bb-92cb-35ceb0f4f185%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to