()
| 1625 | } |
| 1626 | |
| 1627 | func (label *Label) Update() { |
| 1628 | |
| 1629 | label.Highlighter.Highlighting = false |
| 1630 | |
| 1631 | if label.Editing && globals.Keybindings.Pressed(KBNewCardOfPrevType) { |
| 1632 | label.EndEditing() |
| 1633 | return |
| 1634 | } |
| 1635 | |
| 1636 | clickedOut := false |
| 1637 | |
| 1638 | if label.HorizontalAlignment == AlignCenter { |
| 1639 | label.Offset.X = (label.Rect.W - label.RendererResult.TextSize.X) / 2 |
| 1640 | } else if label.HorizontalAlignment == AlignRight { |
| 1641 | label.Offset.X = (label.Rect.W - label.RendererResult.TextSize.X) |
| 1642 | } |
| 1643 | |
| 1644 | if label.RendererResult != nil { |
| 1645 | |
| 1646 | activeRect := &sdl.FRect{label.Rect.X, label.Rect.Y, label.Rect.W, label.Rect.H} |
| 1647 | // activeRect.W = label.RendererResult.Image.Size.X |
| 1648 | // activeRect.H = label.RendererResult.Image.Size.Y |
| 1649 | |
| 1650 | label.MousedOver = false |
| 1651 | |
| 1652 | if globals.State != StateTextEditing && label.Editing { |
| 1653 | label.EndEditing() |
| 1654 | } |
| 1655 | |
| 1656 | if label.Editable && (globals.State == StateNeutral || (globals.State == StateTextEditing && label.Editing)) { |
| 1657 | |
| 1658 | if !label.Editing && ClickedInRect(activeRect, label.WorldSpace) && globals.Mouse.Button(sdl.BUTTON_LEFT).PressedTimes(2) { |
| 1659 | globals.Mouse.Button(sdl.BUTTON_LEFT).Consume() |
| 1660 | label.BeginEditing() |
| 1661 | } |
| 1662 | |
| 1663 | mousePos := globals.Mouse.Position() |
| 1664 | if label.WorldSpace { |
| 1665 | mousePos = globals.Mouse.WorldPosition() |
| 1666 | } |
| 1667 | |
| 1668 | if label.Editing { |
| 1669 | |
| 1670 | globals.State = StateTextEditing |
| 1671 | |
| 1672 | if ClickedOutRect(activeRect, label.WorldSpace) || globals.Keyboard.Key(SDLK_ESCAPE).Pressed() { |
| 1673 | label.EndEditing() |
| 1674 | clickedOut = true |
| 1675 | } |
| 1676 | |
| 1677 | if globals.Keyboard.Key(SDLK_RIGHT).Pressed() { |
| 1678 | |
| 1679 | advance := 1 |
| 1680 | |
| 1681 | if globals.Keyboard.Key(SDLK_LCTRL).Held() { |
| 1682 | |
| 1683 | start := label.Selection.CaretPos |
| 1684 | offset := 0 |
nothing calls this directly
no test coverage detected