Calculating the Insertion Point for Dragged Text Dropped on a Presentation Manager Entry Field
Original Publication Date: 1994-Sep-01
Included in the Prior Art Database: 2005-Mar-27
The OS/2* 2.1 Presentation Manager* (PM) graphical user interface provides operating system level support for drag-drop operations. Using this support, applications have provided drag-drop support for icons within and between containers.
Calculating the Insertion Point for Dragged Text Dropped
on a Presentation
Manager Entry Field
The OS/2* 2.1
Presentation Manager* (PM) graphical user
interface provides operating system level support for drag-drop
operations. Using this support, applications have provided drag-drop
support for icons within and between containers.
type of object can be dragged and dropped using
the provided APIs, messages and protocols. One of the best choices
for this support is text. For example, the text in entry fields
should be able to be dragged and dropped onto other entry fields.
This will enable the application user to copy or move text from one
entry field to another.
the Common User Access* (CUA) standards, the
dropped text should be inserted in an intuitive manner into the text
in the entry field it is dropped on. The easiest implementation of
this is to insert it at the cursor location. This is easy to
implement because the entry field cursor location can be queried with
a single message to the entry field, EM_QUERYSEL, and this cursor
location does not change as a drag-drop operation takes place. This
is what clipboard operations do.
drag-drop operations are performed using the mouse,
however, the ideal and most intuitive solution would be to insert the
dropped text at the point that the mouse is over when the drop
occurs. This allows the user to have complete control over the
insertion point at the time of the drop, rather than having to set
the insertion point in advance by giving the target entry field the
focus and positioning the cursor in it before the drag begins.
multiple problems encountered in attempting to
calculate this position, however. This disclosure describes exactly
how the drop insertion point in a PM single-line entry field can be
calculated, taking into account such factors as scrolled text,
proportional fonts, entry field borders, and the current text in the
have an undocumented border surrounding them of
two dialog units in each direction. This means that the text is
indented within the confines of the entry field's window rectangle.
Since dialog units are directly related to the font being used, this
border must be converted into the number of pels that it currently
takes up. This is discovered by calling the WinMapDlgPoints API,
passing in a point of 2x2 dialog units, and receiving in return the
number of pels this currently entails.
fields allow scrolling of text, the first character
displayed in the target entry field may not be the first character in
the full string currently entered in that entry field. To get the
position in the string of the first character displayed, the
EM_QUERYFIRSTCHAR message must be sent to the entry field. This
message returns the zero-based position of the first displayed
The current text...