MCPcopy Create free account
hub / github.com/cogentcore/core / charPos

Method charPos

core/textfield.go:1252–1259  ·  view source on GitHub ↗

charPos returns the relative starting position of the given rune, in the overall RenderAll of all the text. These positions can be out of visible range: see CharRenderPos

(idx int)

Source from the content-addressed store, hash-verified

1250// in the overall RenderAll of all the text.
1251// These positions can be out of visible range: see CharRenderPos
1252func (tf *TextField) charPos(idx int) math32.Vector2 {
1253 if idx <= 0 || len(tf.renderAll.Spans) == 0 {
1254 return math32.Vector2{}
1255 }
1256 pos, _, _, _ := tf.renderAll.RuneRelPos(idx)
1257 pos.Y -= tf.renderAll.Spans[0].RelPos.Y
1258 return pos
1259}
1260
1261// relCharPos returns the text width in dots between the two text string
1262// positions (ed is exclusive -- +1 beyond actual char).

Callers 2

relCharPosMethod · 0.95
autoScrollMethod · 0.95

Calls 1

RuneRelPosMethod · 0.45

Tested by

no test coverage detected