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

Function TextAreaAt

Siv3D/src/Siv3D/SimpleGUI/SivSimpleGUI.cpp:1123–1682  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1121 }
1122
1123 bool TextAreaAt(TextAreaEditState& text, const Vec2& center, const SizeF& size, const size_t maxChars, const bool enabled)
1124 {
1125 text.cursorPos = Min(text.cursorPos, text.text.size());
1126
1127 const Font& font = SimpleGUI::GetFont();
1128 const int32 fontHeight = font.height();
1129
1130 const String previousText = text.text;
1131 const String editingText = ((text.active && enabled) ? TextInput::GetEditingText() : U"");
1132
1133 // テキストを更新する
1134 {
1135 if (text.active && enabled)
1136 {
1137 // text.text を更新する
1138 text.cursorPos = TextInput::UpdateText(text.text, text.cursorPos, TextInputMode::AllowEnterTabBackSpaceDelete);
1139
1140 # if not SIV3D_PLATFORM(WEB)
1141
1142 // ショートカットキーによるペースト
1143 if ((not editingText) &&
1144 # if SIV3D_PLATFORM(MACOS)
1145 ((KeyCommand + KeyV).down() || (KeyControl + KeyV).down())
1146 # else
1147 (KeyControl + KeyV).down()
1148 # endif
1149 )
1150 {
1151 if (String paste; Clipboard::GetText(paste))
1152 {
1153 text.text.insert(text.cursorPos, paste);
1154 text.cursorPos += paste.size();
1155 }
1156 }
1157
1158 # endif
1159 }
1160
1161 // 最大字数を超えていたら削る
1162 if (maxChars < text.text.size())
1163 {
1164 text.text.resize(maxChars);
1165 text.cursorPos = Min(text.cursorPos, maxChars);
1166 }
1167
1168 // 文字列に変更があったかを調べる
1169 text.textChanged = (text.text != previousText);
1170
1171 // 文字列に変更があれば
1172 if (text.textChanged)
1173 {
1174 // カーソル点滅をリセットする
1175 text.cursorStopwatch.restart();
1176
1177 // グリフを再構築する
1178 text.rebuildGlyphs();
1179 }
1180 }

Callers 1

TextAreaFunction · 0.85

Calls 15

GetEditingTextFunction · 0.85
UpdateTextFunction · 0.85
OnClientRectFunction · 0.85
WheelFunction · 0.85
InRangeFunction · 0.85
EmptyFunction · 0.85
PosFFunction · 0.85
TextAreaDrawFunction · 0.85
rebuildGlyphsMethod · 0.80
resetStopwatchesMethod · 0.80
MinFunction · 0.50
GetTextFunction · 0.50

Tested by

no test coverage detected