void TextBox::OnFocusAcquired() { assert(SDL_IsTextInputActive() == SDL_FALSE); m_caret.StartAnimation(); SetBorderColor(SDLColor(64, 64, 128, 0)); auto loc = GetLocation(); SDL_SetTextInputRect(&loc); SDL_StartTextInput(); }
TextBox::TextBox(Window* pWindow, const SDL_Rect& location) : Control(pWindow, location), m_caret(pWindow, SDLRect(location.x + TextOffsetX, location.y + 8, CaretWidth, location.h - 16)), m_pPrevCursor(nullptr), m_position(0), m_clipOffset(0) { SetBorderColor(SDLColor(128, 128, 128, 0)); SetBorderSize(1); // place the caret above the text box m_caret.SetZOrder(GetZOrder() + 1); }
#include <SDL/SDL_gfxPrimitives.h> #include <SDL/SDL_image.h> #include "utils/cpp_macros.h" #include "utils/fail.h" #include "dashboard.h" #define SIM_EVENT_DO_FRAME 0 // TODO: add cleanup for TTF_* objects #define DEFAULT_NAME "Dashboard" // NB: We don't use SDLColor::BLACK here, lest we fall afoul of the SIOF const SDLColor Dashboard::DEFAULT_COLOR = SDLColor(0,0,0); const int Dashboard::DEFAULT_FONT_SIZE = 11; const int Dashboard::FRAME_INTERVAL_MSEC = 50; Dashboard::Dashboard(const char *bkgd_image_filename) : Entity(DEFAULT_NAME) { init(0, 0, bkgd_image_filename); } Dashboard::Dashboard(int width, int height) : Entity(DEFAULT_NAME) { init(width, height, NULL); } Dashboard::Dashboard(Json::Value &json_data, EntityLookup *lookup) : Entity(DEFAULT_NAME, json_data) {
void TextBox::OnFocusLost() { m_caret.StopAnimation(); SetBorderColor(SDLColor(128, 128, 128, 0)); SDL_StopTextInput(); }