SelectionStart and SelectionLength for WebTextArea?

I have an Editor on Desktop that uses DesktopTextArea.SelectionStart and DesktopTextArea.SelectionLength when performing a Find+Replace function. Now I want the same functionality with a WebTextArea, but those Values are not available. I have also tried GraffitiTextfield, but it also has no SelectionStart and SelectionLength values.

Is there a workaround?

I presume you could use the same javascript I used for a webcombobox

Thanks @Jean-Yves_Pochez, I will definitely use that, but I don’t need to set the selection, only return what the selection is currently.

it seems you can use : (ps: not tested)

    var offset = 0;
    var selection = window.getSelection();
    var range = selection.getRangeAt(0);
    var start = range.startOffset;
    var end = range.endOffset;

Thank you, I’ll give this a test.

Hi David,
I saw this post and added the following to GraffitiTextField for the next release:

Added: GraffitiTextField has a new SelectAll method. (101)
Added: GraffitiTextField has a new SelectionLength as Integer property. (101)
Added: GraffitiTextField has a new SelectionStart as Integer property. (101)

I’m happy to add features most of the time, and it would probably happen quickly if you open Feature Requests in my support system. I’ve opened a ticket for you and provided the updated class.

Thank you @Anthony_G_Cyphers, very quick!

1 Like