renderCursor renders the cursor on or off, as a sprite that is either on or off
(on bool)
| 1340 | |
| 1341 | // renderCursor renders the cursor on or off, as a sprite that is either on or off |
| 1342 | func (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 |
no test coverage detected