Background:
In the actual use of the project, multiple elements are dragged to the specified area, and the elements belong to different types. After you drag and drop the first element, and then drag the other elements, you will find that the first element is dragged again.
Course:
1, online search, did not get the answer;
2, flip through the source code of Actionchains, found that it is to store all the action in a _actions variable. Then execute all the actions stored in this array in the Perform method. The code is as follows:
def perform (self):
"""
Performs all stored actions.
"""
For action in Self._actions:
Action ()
The question should be: in the second drag, the _actions array still retains its first drag operation.
The workaround is to empty the _actions array before each drag.
The first idea is whether the action_chains itself has emptied the _actions array. Search throughout the action_chains.py, and no corresponding method was found.
Since there is no, only in your own code, before each execution, the data _actions empty.
Once again, the drag-and-drop code is repeated, and there is no repetition of dragging elements. You can also use eclipse break points to see what the values in this array are at execution time.
When you use the Actionchains class, you drag and drop once, and then drag the previous element repeatedly.