How do I Send Messages During A Drag Operation?

When performing a drag/drop operation in Revolution the dragMove message is sent when the mouse is moving. The engine does not send any messages while the mouse is not moving (not even idle). In addition you cannot use send message in time to trigger handlers. The engine will just queue any messages you send and process them once the drag operation has finished. This can be problematic if you want to perform an operation while the mouse is not moving. This lesson shows one workaround.

Use a Repeat Loop

The only time you can call handlers during a drag operation is during one of the drag events. In order to call a handler while the mouse is not moving you can use a repeat loop in dragMove. The repeat loops until the mouse location is not the same as it was when dragMove was called or the mouse button is released.

on dragMove pMouseH, pMouseV

## Perform some operation until the mouse moves again

## In this case the command AutoScrollTheField is called

repeat until (the mouseloc is not pMouseH,pMouseV) or (mouse(1) is "up" and mouse(3) is "up")


end repeat

end dragMove

Note: I check mouse(1) and mouse(3) as those are two buttons that could start a drag operation.



This technique can be useful in situations where you want to automatically scroll the group or field that the cursor is over during a drag operation. For example, if the user rests the mouse near the bottom or top of a group then it is common for the group to scroll down or up so the user can drop the item elsewhere in the list.


Add your comment

E-Mail me when someone replies to this comment