From 1c01623f2fb47da542c5703f485b6fd062d88c80 Mon Sep 17 00:00:00 2001 From: Pablo Amorin Date: Fri, 30 Nov 2018 10:29:17 -0300 Subject: [PATCH] [FIX] InputText clears field on focus [FEATURE] Param cursor blinking speed --- oxygine/src/oxygine/InputText.cpp | 10 ++++++---- oxygine/src/oxygine/InputText.h | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/oxygine/src/oxygine/InputText.cpp b/oxygine/src/oxygine/InputText.cpp index fae18d692..02ee3c09d 100644 --- a/oxygine/src/oxygine/InputText.cpp +++ b/oxygine/src/oxygine/InputText.cpp @@ -11,10 +11,12 @@ namespace oxygine { InputText* InputText::_active = 0; - InputText::InputText(): _maxLength(0) + InputText::InputText(int cursorSpeed): _maxLength(0) { _cursor = new ColorRectSprite; - _cursor->addTween(Actor::TweenAlpha(0), 400, -1, true); + if (cursorSpeed > 0) { + _cursor->addTween(Actor::TweenAlpha(0), cursorSpeed, -1, true); + } _cursor->setVisible(false); } @@ -59,7 +61,7 @@ namespace oxygine SDL_StartTextInput(); - _txt = ""; + _txt = ta->getText(); updateText(); } @@ -231,4 +233,4 @@ namespace oxygine } return 0; } -} \ No newline at end of file +} diff --git a/oxygine/src/oxygine/InputText.h b/oxygine/src/oxygine/InputText.h index 8288138f8..e74df956e 100644 --- a/oxygine/src/oxygine/InputText.h +++ b/oxygine/src/oxygine/InputText.h @@ -15,7 +15,7 @@ namespace oxygine enum {EVENT_TEXT_CHANGED = sysEventID('I', 'T', 'C') }; enum {EVENT_COMPLETE = Event::COMPLETE}; - InputText(); + InputText(int cursorSpeed = 400); ~InputText(); /**Shows virtual keyboard(if supported on platform) and sends pressed chars to TextField*/ @@ -47,4 +47,4 @@ namespace oxygine void _onSysEvent(Event* event); int _onSDLEvent(SDL_Event* event); }; -} \ No newline at end of file +}