I have been using ContainerList with drag and drop functionality in the past. Since ContainerList has been deprecated I am now trying to use something different. As recommended in the documentation I would like to use just a Container with BoxLayout in the y-axis.
However looking into that this seems to be rather difficult, too.
What I am trying to (re-)create ist a list of entries containing with labels and buttons which entries van be sorted by a longPointerPress followed by drag and drop.
In the past I managed to do this by heavily modifying the ContainerList and ContainerList.Entry classes.
But with a Container I cannot see how to do this at all.
As I see it this would involve:
creation of a ListEntry component derived from Container and overriding de.sae.tryout.modules.dragdrop.DraggableContainer.getComponentAt(int, int) to always return this to intercept all of the pointer interactions and
depending of its state passing through the pointer events to the child components if it is appropriate
Since this seems to me as an inadmissible trick the question: What is the recommended way to display such a sortable list of entries where each entry contains some labels and buttons?
Since every entry would be a lead component to make it feel like a container list just using setDraggable(true) on the lead component and setDropTarget(true) on the parent will allow drag and drop.
Notice this won't have the same behavior as you have now with the long pointer press which might be a problem but might not. If this is a problem you can override the drag initialization behavior of the lead component to make it closer to the way it worked.
Related
with my team mates we are trying to implement a tree in React using react-complex-tree. We are using the controlled Environment because we want to make the user able to add and remove items. We are also implementing the Drag and drop mechanism, we filled the onDrop event and the "putting an item inside another" mechanism works. If we don't expand any Item also the reordering mechanism works, buf if we expand some Items and we try to move some child became all broken! The "target" element is wrong and in some cases (with the elements on bottom of the tree) also the "item" array is wrong!!! On "bestofreactjs.com" there is the issue #15, and seems to be similar. We are in trouble, this problems is making lose a big amount of time! How can we fix it ? Thanks all for the answers.
What approach to do intelligent drag drop like this in react? (canvas or non-canvas based approach?). That is to use React (with a library such as React DND) without using cavas, OR move to rendering/drawing this within React using HTML 5 "canvas" (with potentially a library such as "react-konva".
Requirements:
when dragging the item, the other items behind "move" to calculate
and show what the final re-arrangement will look like (if the drag is
allowable)
may be drop points for which move is not allowed so would highlight
this as well (e.g. if some other items in the timeline were "locked")
I have checked React DND, react-konva, and others. The issue they use the transform property and that prevents moving the placeholder separately from dragging the item.
So here is the custom implementation: https://codesandbox.io/s/drag-swap-qv6s0x
P.S
It is still unfinished (buggy), later I will fix and clean up the code. But for now, I would like to share it, to know is it what you wanted or if I missing something.
Have a look at this online documentation for MDBootstrap:
https://mdbootstrap.com/docs/standard/plugins/drag-and-drop/
Go to "Horizontal example" section, this might be what you are looking for.
Edit: Sadly this is a premium feature :(
I want to create a list of switches (or custom controls that handle horizontal pointer movements).
That is easily done by putting those components in a Container using BoxLayout.y as LayoutManager.
But because the components (the horizontally movable Switch or custom components) take a lot of room in the list it is very difficult to scroll the list. This is because all the pointer events are handled by the nested components and none get through to the surrounding Container - the one with the BoxLayout.y.
The natural thing I tried to do was to call the respective pointer...-Methods of the parent Container - which turned out to be a stupid idea - it led to a StackOverflowError.
What I really would like to do was handle the pointer events in both the child and the parent Components for a certain threshold distance on order to determine whether the user wants to scroll horizontally or vertically.
I noticed that with nested BoxLayout.x-Containers nested in a BoxLayout.y-Container this works out of the box. But I haven't been able to grasp how to achieve that with a custom control - and it does not work the the CN1-Switch-Components either.
The question is: How do do this in a reasonable manner? Is it even possible? Or would that require gesture detection which is not (yet) part of Codename One?
This is the default behavior of Codename One. Scrolling takes over and there are biases based on the X/Y axis you use. All of that is built in. As I recall you changed a lot of default behaviors in Codename One, I suggest trying a clean project and seeing how it works e.g. with something like this: https://www.codenameone.com/blog/button-lists.html
I have an InfiniteContainer list where each element is a relatively complex container with several different buttons with each their action. Since it's a scrollable list, I use LongPointerPress to activate drag and drop like Shai recommended in another post. To do this I need to set a lead component to handle this. However, when I set it, none of the other buttons get their individual events. I thought I could overwrite the getLeadComponent() of the buttons to have it return null, to ensure those buttons handle their own events, but it's private and haven't been able to think of any other solution for now.
Is there a recommended approach for handling this?
NB. I've been spending a LOT of time piecing together partial advice from different posts, and using trial and error to get this UI to work. It would be useful if the CN1 documentation could contain more explicit advice on the approaches that work for such 'real life' complex UI which combine eg lists, drag&drop, multiple buttons, long press for additional actions, Swipable containers, ... It shouldn't feel like constant hacking ;-)
You can setLeadComponent(null) when you are done with the lead component functionality to "undo" the lead component effect. The lead component behavior is an "all or nothing" approach.
If this doesn't work for you you can override the low level events in the Form and implement the functionality there. You can block components from getting events by not calling super.pointer* methods in Form and thus allow any sort of effect.
I am optimizing my application. Originally, it's a Ext.TabPanel but I decided to use only a Ext.TabBar docked at the bottom and change the views above, so it requires a lot of add/remove actions from my main Ext.Container.
So my question is: in what way I should do to add/remove items from my Ext.Container effectively? I mean: fast, not cause memory-leaks, and also, not cause error like this: the view with a button in it, firstly added, all handlers (which are define through refs and control in a controller) work well but the second time (i.e it's removed and added again later), all handlers die.
Thanks in advance!
You have to ensure that you destroy the panel is destroyed otherwise it would be sitting in the dom.
Generally to remove a component from a container you use the Container remove() function which takes in the first parameter as the item to be removed and the second one is a boolean which instructs for it to be destroyed or not. You should ensure you set it to true to make sure you keep your DOM as lean as possible. Unless you're going to be reusing that component in the near future and do not want to render it again, then you do not need to destroy it.
http://docs.sencha.com/touch/2-0/#!/api/Ext.Container-method-remove