This forum is temporaily read-only. All existing discussions remain available for reference. For new questions, bug reports or support requests, please contact us at mail@lmdsupport.com.

LMDRichEdit TLMDSelectionType

hello how to use LMDRichEdit.SelectionType

stText Text
stObject At least one OLE object
stMultiChar More than one character of text
stMultiObject More than one OLE object

THANKS

Comments

  • Your question is too general. This is one of the properties, which describes rich edit current state. An application can use it to show/hide or enable/disable some actions or menu items, for example.
  • edited April 2024
    hello, yes it is for this purpose that I would like to use this function.
    I can't use this function, how to encapsulate RichEdit.SelectionType & TLMDRichSelection.

    // TPopUpMenu OnPopup
    procedure TForm.PopUpRichPopup(Sender: TObject);
    begin
      case RichEdit.SelectionType of
        stText:
          ShowMessage('Text');
        stObject:
          ShowMessage('Object');
        stMultiChar:
          ShowMessage('MultiChar');
        stMultiObject:
          ShowMessage('MultiObject');
      end;
    end;

    or
    if RichEdit.SelectionType = TLMDRichSelection.stText then

    Thanks a lot

  • SelectionType is a set property, you can read more here:

    https://docwiki.embarcadero.com/RADStudio/Sydney/en/Structured_Types_(Delphi)#Sets

    So, several flags can be set simultaneously, and you can check for them like this:

    procedure TForm.PopUpRichPopup(Sender: TObject);
    begin
      if stText in RichEdit.SelectionType then
        ShowMessage('Text');
      if stObject in RichEdit.SelectionType then
        ShowMessage('Object');
      if stMultiChar in RichEdit.SelectionType then
        ShowMessage('MultiChar');
      if stMultiObject in RichEdit.SelectionType then
        ShowMessage('MultiObject');
    end;

    or like this:

    procedure TForm.PopUpRichPopup(Sender: TObject);
    begin
      if RichEdit.SelectionType = [stText, stObject] then
        ShowMessage('Text and object');
    end;
  • I think I found

      if RichEdit.SelectionType = [stText, stMultiChar] then
          ShowMessage('Text')
      else if RichEdit.SelectionType = [stObject] then
          ShowMessage('Object');
Sign In or Register to comment.