setCursorFromPixel finds cursor location from given scene-relative pixel location, and sets current cursor to it, updating selection too.
(pt image.Point, selMode events.SelectModes)
| 1607 | // setCursorFromPixel finds cursor location from given scene-relative |
| 1608 | // pixel location, and sets current cursor to it, updating selection too. |
| 1609 | func (tf *TextField) setCursorFromPixel(pt image.Point, selMode events.SelectModes) { |
| 1610 | oldPos := tf.cursorPos |
| 1611 | tf.cursorPos = tf.pixelToCursor(pt) |
| 1612 | if tf.selectMode || selMode != events.SelectOne { |
| 1613 | if !tf.selectMode && selMode != events.SelectOne { |
| 1614 | tf.selectStart = oldPos |
| 1615 | tf.selectMode = true |
| 1616 | } |
| 1617 | if !tf.StateIs(states.Sliding) && selMode == events.SelectOne { // && tf.CursorPos >= tf.SelectStart && tf.CursorPos < tf.SelectEnd { |
| 1618 | tf.selectReset() |
| 1619 | } else { |
| 1620 | tf.selectRegionUpdate(tf.cursorPos) |
| 1621 | } |
| 1622 | tf.selectUpdate() |
| 1623 | } else if tf.hasSelection() { |
| 1624 | tf.selectReset() |
| 1625 | } |
| 1626 | tf.NeedsRender() |
| 1627 | } |
| 1628 | |
| 1629 | func (tf *TextField) handleKeyEvents() { |
| 1630 | tf.OnKeyChord(func(e events.Event) { |
no test coverage detected