Example for exercising tree control (enhanced to support drag-n-drop of items with scrolling) in Pythoncard. The code is based on the "TreeCtrl with automatic scrolling while dragging" sample code found in:
"The following sample script demonstrates how to achieve automatic scrolling while dragging an item beyond the visible area of a tree control. In the sample only the lowest level items can be dragged.
Here's briefly how it works:
* In the DRAG_BEGIN event handler the tree binds to MOTION events.
* In the MOTION event handler, in case the mouse pointer leaves the tree control, a wx.Timer is started.
* The TIME event handler will scroll up/down one step in case the pointer is still outside the tree control and start a new wx.Timer. If not, the timer object is deleted. A new wx.Timer might be started from the MOTION event handler.
* The tree unregisters for the MOTION event when recieving a LEFT_UP event.
The methods that do the scrolling account for the differences between wxGTK and wxMSW. Note that automatic scrolling on wxMSW works only, if the tree control has an image list associated with it, thus showing little icons left to the text.
Log in to post a comment.