summaryrefslogtreecommitdiff
path: root/src/ui/inputwidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r--src/ui/inputwidget.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 1c6b8d9e..ea7ed523 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -596,10 +596,19 @@ static size_t length_InputWidget_(const iInputWidget *d) {
596} 596}
597 597
598static int contentHeight_InputWidget_(const iInputWidget *d) { 598static int contentHeight_InputWidget_(const iInputWidget *d) {
599 if (d->sysCtrl) {
600 const int preferred = preferredHeight_SystemTextInput(d->sysCtrl);
601 return iClamp(preferred,
602 d->minWrapLines * lineHeight_Text(d->font),
603 d->maxWrapLines * lineHeight_Text(d->font));
604 }
599 return size_Range(&d->visWrapLines) * lineHeight_Text(d->font); 605 return size_Range(&d->visWrapLines) * lineHeight_Text(d->font);
600} 606}
601 607
602static void updateTextInputRect_InputWidget_(const iInputWidget *d) { 608static void updateTextInputRect_InputWidget_(const iInputWidget *d) {
609 if (d->sysCtrl) {
610 setRect_SystemTextInput(d->sysCtrl, contentBounds_InputWidget_(d));
611 }
603#if !defined (iPlatformAppleMobile) 612#if !defined (iPlatformAppleMobile)
604 const iRect bounds = bounds_Widget(constAs_Widget(d)); 613 const iRect bounds = bounds_Widget(constAs_Widget(d));
605 SDL_SetTextInputRect(&(SDL_Rect){ bounds.pos.x, bounds.pos.y, bounds.size.x, bounds.size.y }); 614 SDL_SetTextInputRect(&(SDL_Rect){ bounds.pos.x, bounds.pos.y, bounds.size.x, bounds.size.y });
@@ -1036,6 +1045,7 @@ void systemInputChanged_InputWidget_(iSystemTextInput *sysCtrl, void *widget) {
1036 iInputWidget *d = widget; 1045 iInputWidget *d = widget;
1037 splitToLines_(text_SystemTextInput(sysCtrl), &d->lines); 1046 splitToLines_(text_SystemTextInput(sysCtrl), &d->lines);
1038 contentsWereChanged_InputWidget_(d); 1047 contentsWereChanged_InputWidget_(d);
1048 updateMetrics_InputWidget_(d);
1039} 1049}
1040#endif 1050#endif
1041 1051
@@ -1050,14 +1060,16 @@ void begin_InputWidget(iInputWidget *d) {
1050 setFlags_Widget(w, selected_WidgetFlag, iTrue); 1060 setFlags_Widget(w, selected_WidgetFlag, iTrue);
1051 mergeLines_(&d->lines, &d->oldText); 1061 mergeLines_(&d->lines, &d->oldText);
1052#if defined (LAGRANGE_ENABLE_SYSTEM_INPUT) 1062#if defined (LAGRANGE_ENABLE_SYSTEM_INPUT)
1053 d->sysCtrl = new_SystemTextInput((d->inFlags & isUrl_InputWidgetFlag ? disableAutocorrect_SystemTextInputFlag : 0) | 1063 d->sysCtrl = new_SystemTextInput(contentBounds_InputWidget_(d),
1064 (d->maxWrapLines > 1 ? multiLine_SystemTextInputFlags : 0) |
1065 (d->inFlags & isUrl_InputWidgetFlag ? disableAutocorrect_SystemTextInputFlag : 0) |
1054 (!cmp_String(id_Widget(w), "url") ? returnGo_SystemTextInputFlags : 0) | 1066 (!cmp_String(id_Widget(w), "url") ? returnGo_SystemTextInputFlags : 0) |
1055 (flags_Widget(w) & alignRight_WidgetFlag ? alignRight_SystemTextInputFlag : 0)); 1067 (flags_Widget(w) & alignRight_WidgetFlag ? alignRight_SystemTextInputFlag : 0));
1056 setFont_SystemTextInput(d->sysCtrl, d->font); 1068 setFont_SystemTextInput(d->sysCtrl, d->font);
1057 setRect_SystemTextInput(d->sysCtrl, contentBounds_InputWidget_(d));
1058 setText_SystemTextInput(d->sysCtrl, &d->oldText); 1069 setText_SystemTextInput(d->sysCtrl, &d->oldText);
1059 setTextChangedFunc_SystemTextInput(d->sysCtrl, systemInputChanged_InputWidget_, d); 1070 setTextChangedFunc_SystemTextInput(d->sysCtrl, systemInputChanged_InputWidget_, d);
1060 iConnect(Root, w->root, visualOffsetsChanged, d, updateAfterVisualOffsetChange_InputWidget_); 1071 iConnect(Root, w->root, visualOffsetsChanged, d, updateAfterVisualOffsetChange_InputWidget_);
1072 updateMetrics_InputWidget_(d);
1061 return; 1073 return;
1062#endif 1074#endif
1063 if (d->mode == overwrite_InputMode) { 1075 if (d->mode == overwrite_InputMode) {