Interface IControlContentAdapter

All Known Implementing Classes:
ComboContentAdapter, TextContentAdapter

public interface IControlContentAdapter
This interface is used to set and retrieve text content from an arbitrary control. Clients are expected to implement this interface when defining a ContentProposalAdapter, in order to specify how to retrieve and set the contents of the control being adapted.
Since:
3.2
  • Method Details

    • setControlContents

      void setControlContents(Control control, String contents, int cursorPosition)
      Set the contents of the specified control to the specified text. Must not be null.
      Parameters:
      control - the control whose contents are to be set (replaced).
      contents - the String specifying the new control content.
      cursorPosition - the zero-based index representing the desired cursor position in the control's contents after the contents are set.
    • insertControlContents

      void insertControlContents(Control control, String contents, int cursorPosition)
      Insert the specified contents into the control's current contents. Must not be null.
      Parameters:
      control - the control whose contents are to be altered.
      contents - the String to be inserted into the control contents.
      cursorPosition - the zero-based index representing the desired cursor position within the inserted contents after the insertion is made.
    • getControlContents

      String getControlContents(Control control)
      Get the text contents of the control.
      Parameters:
      control - the control whose contents are to be retrieved.
      Returns:
      the String contents of the control.
    • getCursorPosition

      int getCursorPosition(Control control)
      Get the current cursor position in the control. The position is specified as a zero-based index into the string. Valid ranges are from 0 to N, where N is the size of the contents string. A value of N indicates that the cursor is at the end of the contents.
      Parameters:
      control - the control whose position is to be retrieved.
      Returns:
      the zero-based index representing the cursor position in the control's contents.
    • getInsertionBounds

      Rectangle getInsertionBounds(Control control)
      Get the bounds (in pixels) of the insertion point for the control content. This is a rectangle, in coordinates relative to the control, where the insertion point is displayed. If the implementer does not have an insertion point, or cannot determine the location of the insertion point, it is appropriate to return the bounds of the entire control. This value may be used to position a content proposal popup.
      Parameters:
      control - the control whose offset is to be retrieved.
      Returns:
      the pixel width representing the distance between the edge of the control and the insertion point.
    • setCursorPosition

      void setCursorPosition(Control control, int index)
      Set the current cursor position in the control. The position is specified as a zero-based index into the string. Valid ranges are from 0 to N, where N is the size of the contents string. A value of N indicates that the cursor is at the end of the contents.
      Parameters:
      control - the control whose cursor position is to be set.
      index - the zero-based index representing the cursor position in the control's contents.