| 762 | } |
| 763 | |
| 764 | bool TextBoxAt(TextEditState& text, const Vec2& center, const double _width, const Optional<size_t>& maxChars, const bool enabled) |
| 765 | { |
| 766 | text.cursorPos = Min(text.cursorPos, text.text.size()); |
| 767 | text.tabKey = false; |
| 768 | text.enterKey = false; |
| 769 | |
| 770 | const Font& font = SimpleGUI::GetFont(); |
| 771 | const int32 fontHeight = font.height(); |
| 772 | |
| 773 | const String previousText = text.text; |
| 774 | const String editingText = ((text.active && enabled) ? TextInput::GetEditingText() : U""); |
| 775 | |
| 776 | // テキストを更新する |
| 777 | { |
| 778 | if (text.active && enabled) |
| 779 | { |
| 780 | // text.text を更新する |
| 781 | text.cursorPos = TextInput::UpdateText(text.text, text.cursorPos, TextInputMode::AllowBackSpaceDelete); |
| 782 | |
| 783 | # if not SIV3D_PLATFORM(WEB) |
| 784 | |
| 785 | // ショートカットキーによるペースト |
| 786 | if ((not editingText) && |
| 787 | # if SIV3D_PLATFORM(MACOS) |
| 788 | ((KeyCommand + KeyV).down() || (KeyControl + KeyV).down()) |
| 789 | # else |
| 790 | (KeyControl + KeyV).down() |
| 791 | # endif |
| 792 | ) |
| 793 | { |
| 794 | if (String paste; Clipboard::GetText(paste)) |
| 795 | { |
| 796 | paste.remove_if([](char32 ch) { return (ch < 0x20) || (ch == U'\x7F'); }); |
| 797 | text.text.insert(text.cursorPos, paste); |
| 798 | text.cursorPos += paste.size(); |
| 799 | } |
| 800 | } |
| 801 | |
| 802 | # endif |
| 803 | } |
| 804 | |
| 805 | // 最大字数を超えていたら削る |
| 806 | if (maxChars && (*maxChars < text.text.size())) |
| 807 | { |
| 808 | text.text.resize(*maxChars); |
| 809 | text.cursorPos = Min(text.cursorPos, *maxChars); |
| 810 | } |
| 811 | |
| 812 | // 文字列に変更があったかを調べる |
| 813 | text.textChanged = (text.text != previousText); |
| 814 | |
| 815 | // 文字列に変更があれば |
| 816 | if (text.textChanged) |
| 817 | { |
| 818 | // カーソル点滅をリセットする |
| 819 | text.cursorStopwatch.restart(); |
| 820 | } |
| 821 | } |
no test coverage detected