Change RangeHighlighter position after adding to MarkupModel

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".

0
5 comments

Please explain the use case requiring to add and then remove highlighters

0

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....

0

Could you please explain a) how you add those markers b) why you want to re-use existing ones.

0

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...

0

w/r b) this seems negligible

0

Please sign in to leave a comment.