diff options
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r-- | src/ui/inputwidget.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c index 05b83b3d..52359732 100644 --- a/src/ui/inputwidget.c +++ b/src/ui/inputwidget.c | |||
@@ -83,6 +83,7 @@ struct Impl_InputWidget { | |||
83 | iArray text; /* iChar[] */ | 83 | iArray text; /* iChar[] */ |
84 | iArray oldText; /* iChar[] */ | 84 | iArray oldText; /* iChar[] */ |
85 | iString hint; | 85 | iString hint; |
86 | iString srcHint; | ||
86 | int leftPadding; | 87 | int leftPadding; |
87 | int rightPadding; | 88 | int rightPadding; |
88 | size_t cursor; | 89 | size_t cursor; |
@@ -136,6 +137,7 @@ void init_InputWidget(iInputWidget *d, size_t maxLen) { | |||
136 | init_Array(&d->text, sizeof(iChar)); | 137 | init_Array(&d->text, sizeof(iChar)); |
137 | init_Array(&d->oldText, sizeof(iChar)); | 138 | init_Array(&d->oldText, sizeof(iChar)); |
138 | init_String(&d->hint); | 139 | init_String(&d->hint); |
140 | init_String(&d->srcHint); | ||
139 | init_Array(&d->undoStack, sizeof(iInputUndo)); | 141 | init_Array(&d->undoStack, sizeof(iInputUndo)); |
140 | d->font = uiInput_FontId | alwaysVariableFlag_FontId; | 142 | d->font = uiInput_FontId | alwaysVariableFlag_FontId; |
141 | d->leftPadding = 0; | 143 | d->leftPadding = 0; |
@@ -164,6 +166,7 @@ void deinit_InputWidget(iInputWidget *d) { | |||
164 | if (d->timer) { | 166 | if (d->timer) { |
165 | SDL_RemoveTimer(d->timer); | 167 | SDL_RemoveTimer(d->timer); |
166 | } | 168 | } |
169 | deinit_String(&d->srcHint); | ||
167 | deinit_String(&d->hint); | 170 | deinit_String(&d->hint); |
168 | deinit_Array(&d->oldText); | 171 | deinit_Array(&d->oldText); |
169 | deinit_Array(&d->text); | 172 | deinit_Array(&d->text); |
@@ -251,8 +254,10 @@ void setMaxLen_InputWidget(iInputWidget *d, size_t maxLen) { | |||
251 | } | 254 | } |
252 | 255 | ||
253 | void setHint_InputWidget(iInputWidget *d, const char *hintText) { | 256 | void setHint_InputWidget(iInputWidget *d, const char *hintText) { |
254 | setCStr_String(&d->hint, hintText); | 257 | /* Keep original for retranslations. */ |
255 | translate_Lang(&d->hint); /* TODO: Keep original for retranslations. */ | 258 | setCStr_String(&d->srcHint, hintText); |
259 | set_String(&d->hint, &d->srcHint); | ||
260 | translate_Lang(&d->hint); | ||
256 | } | 261 | } |
257 | 262 | ||
258 | void setContentPadding_InputWidget(iInputWidget *d, int left, int right) { | 263 | void setContentPadding_InputWidget(iInputWidget *d, int left, int right) { |
@@ -665,6 +670,11 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) { | |||
665 | begin_InputWidget(d); | 670 | begin_InputWidget(d); |
666 | return iFalse; | 671 | return iFalse; |
667 | } | 672 | } |
673 | else if (isCommand_UserEvent(ev, "lang.changed")) { | ||
674 | set_String(&d->hint, &d->srcHint); | ||
675 | translate_Lang(&d->hint); | ||
676 | return iFalse; | ||
677 | } | ||
668 | else if (isCommand_Widget(w, ev, "focus.lost")) { | 678 | else if (isCommand_Widget(w, ev, "focus.lost")) { |
669 | end_InputWidget(d, iTrue); | 679 | end_InputWidget(d, iTrue); |
670 | return iFalse; | 680 | return iFalse; |