MCPcopy Create free account
hub / github.com/Siv3D/OpenSiv3D / TextBoxAt

Function TextBoxAt

Siv3D/src/Siv3D/SimpleGUI/SivSimpleGUI.cpp:764–1104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 }

Callers 1

TextBoxFunction · 0.85

Calls 15

GetEditingTextFunction · 0.85
UpdateTextFunction · 0.85
OnClientRectFunction · 0.85
RequestStyleFunction · 0.85
PosFFunction · 0.85
GetRawInputFunction · 0.85
GetTextColorFunction · 0.85
GetCandicateCursorIndexFunction · 0.85
SetFocusToTextInputFunction · 0.85
SyncronizeTextFunction · 0.85
SetCursorIndexFunction · 0.85
resetStopwatchesMethod · 0.80

Tested by

no test coverage detected