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

Method renderCursor

core/textfield.go:1342–1370  ·  view source on GitHub ↗

renderCursor renders the cursor on or off, as a sprite that is either on or off

(on bool)

Source from the content-addressed store, hash-verified

1340
1341// renderCursor renders the cursor on or off, as a sprite that is either on or off
1342func (tf *TextField) renderCursor(on bool) {
1343 if tf == nil || tf.This == nil {
1344 return
1345 }
1346 if !on {
1347 if tf.Scene == nil {
1348 return
1349 }
1350 ms := tf.Scene.Stage.Main
1351 if ms == nil {
1352 return
1353 }
1354 spnm := fmt.Sprintf("%v-%v", textFieldSpriteName, tf.fontHeight)
1355 ms.Sprites.InactivateSprite(spnm)
1356 return
1357 }
1358 if !tf.IsVisible() {
1359 return
1360 }
1361
1362 tf.cursorMu.Lock()
1363 defer tf.cursorMu.Unlock()
1364
1365 sp := tf.cursorSprite(on)
1366 if sp == nil {
1367 return
1368 }
1369 sp.Geom.Pos = tf.charRenderPos(tf.cursorPos, true).ToPointFloor()
1370}
1371
1372// cursorSprite returns the Sprite for the cursor (which is
1373// only rendered once with a vertical bar, and just activated and inactivated

Callers 3

startCursorMethod · 0.95
clearCursorMethod · 0.95
initFunction · 0.45

Calls 7

cursorSpriteMethod · 0.95
charRenderPosMethod · 0.95
InactivateSpriteMethod · 0.80
ToPointFloorMethod · 0.80
IsVisibleMethod · 0.65
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected