Change RangeHighlighter position after adding to MarkupModel Follow
Hey,
does anyone know how to change the position of a RangeHighlighter after adding it to the MarkupModel? My current idea is to remove the highlighter and to add it with the new position, but this would cause many, many short lived objects on runtime - so I would like to avoid this "workaround".
Please sign in to leave a comment.
Please explain the use case requiring to add and then remove highlighters
Adding and removing highlighters is just a workaround, if there is no other way.
I just want to change the position of a RangeHighlighter, but I don't know how and research didn't gave me the results I wanted....
Could you please explain a) how you add those markers b) why you want to re-use existing ones.
Sry for the late answer, I had a little bit stress the last weeks/months...
a)
That's how I add a new Highlighter:
editor.getMarkupModel().addRangeHighlighter(
startOffset,
endOffset,
HighlighterLayer.ERROR + layerOffset,
attributes, // TextAttributes defining the color etc.
HighlighterTargetArea.EXACT_RANGE
);
b) Mainly performance reasons: Creating and deleting objects everytime something changes would trigger the GC for no reason. As an indie game dev this way hurts...
w/r b) this seems negligible