
the same as the value retur ned by getCharIndex(). isLeadingEdge() specifies whether the hit
was on the leading edge of the character.
If you want to place the insertion cursor at the position of the mouse click, it is not suf-
ficient to know which character was clicked on; you must also know whether the lead-
ing edge or the trailing edge of the character was clicked on. This is particularly
important when working with bidirectional text, such as Arabic or Hebrew. If the TextHit-
Info specifies that the trailing edge was selected, the insertion cursor should be placed
befor e the character. Otherwise, it should be placed after the character.
In bidirectional text, positioning the cursor correctly in response to user requests to
move it left or right can be quite tricky. TextHitInfo is also retur ned by the getNextLeftHit()
and getNextRightHit() methods of TextLayout,tohelp solve this problem.
public final class TextHitInfo {
// No Constructor
// Public Class Methods
public static TextHitInfo afterOffset(int offset);
public static TextHitInfo beforeOffset(int offset);
public static TextHitInfo leading(int charIndex);
public static TextHitInfo trailing(int charIndex);
// Property Accessor Methods (by property name)
public int getCharIndex();
public int getInser tionIndex();
public boolean isLeadingEdge();
public TextHitInfo getOtherHit();
// Public Instance Methods
public boolean equals(TextHitInfo hitInfo ...