- 18.07 (released) ...
EiffelVision Pick and Drop
Pick-and-Drop is a unique user-interface action that permits a user to request an action be performed on a specified object. It is a more-ergonomic alternative to the typical drag-and-drop or "select-and-click" user operations found in most modern graphical user interfaces. Users of EiffelStudio have come to value Pick-and-Drop as both intuitive, and easier on the wrist and fingers with long-term use.
Pick-and-Drop uses the metaphor of pebbles and holes. The typical method of doing a pick-and-drop is that the end user selects the object to receive an action with a single right-click of the mouse. At that point, the mouse arrow turns into a "pebble" connected to the "point of picking" via a visible "band". This "pebble" is often a symbol representing the type of object that was "picked". In the case of the screen-shot below, it is a blue ellipse: the "pebble" symbol for a class.
The "pebble" may then be dropped into any compatible "hole" (drop target—a widget configured to accept "pebbles" of this type). Such "receiving" widgets are often tool-bar buttons or editing areas (or in the case of the screen-shot above, the editor "tab" bar), but can be any widget that inherits from EV_PICK_AND_DROPABLE and is properly configured. The user then can either "drop the pebble into the hole" with a second right-click (on the receiving object), or may cancel the operation by single-clicking the left mouse button.
Because the Pick-and-Drop operation has been so popular, classes have been added to the EiffelVision 2 library to make implementing this user interface very easy.
From a technical viewpoint, Pick-and-Drop is a mechanism which allows data to be transported from a source object to a target. Any EiffelVision 2 object inheriting from EV_PICK_AND_DROPABLE can be used to transport or receive data.
A Simple Pick-and-Drop Example
The following steps need to be undertaken to set up a simple pick and drop:
- Set the source by calling set_pebble.
- Set one or more targets by adding an agent to their
drop_actionslist. To make the target accept that type of pebble, the arguments of the agent must match the type of the pebble to be transported for the source. Otherwise the transport will not be permitted.
A simple example of this is demonstrated here:
button1.set_pebble ("A PND transport has occured%N")
button2.drop_actions.extend (agent print (?))
Three Different Modes of Transport
There are three different modes of transport available for pick and drop. They are listed below with details of their use:
- Pick and Drop Mode.
- Drag and Drop Mode
- Target Menu Mode
This is the default mode for pick and drop, but can be set by calling
set_pick_and_drop_modeon the source object. Right clicking on a source starts the transport and right clicking on a valid target completes the transport. During execution, a band is drawn from the screen position where the pick started to the current mouse position. Pressing the left mouse button or the escape key during execution will end the transport. This mode can be set by calling set_drag_and_drop_modeon the source object. Left clicking on a source starts the transport and releasing the left mouse button over a valid target completes the transport. During execution, a band is drawn from the screen position where the pick started to the current mouse position. Releasing the left mouse button or pressing the escape key during execution will end the transport. This mode can be set by calling set_target_menu_modeon the source object. Right clicking on a source brings up a menu of all the valid drop targets in the system. Selecting one of these targets completes the transport.
Accept and Deny Cursors