Created
January 3, 2020 22:31
-
-
Save ermiry/7d418001b7c7356f48ca265174350f28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "cengine/renderer.h" | |
#include "cengine/ui/ui.h" | |
#include "cengine/ui/font.h" | |
#include "cengine/ui/inputfield.h" | |
void input_field_create () { | |
Renderer *main_renderer = renderer_get_by_name ("main"); | |
Font *font = ui_font_get_default (); | |
// creates a new input field with dimensions 400x40 | |
InputField *input = ui_input_field_create (0, 0, 400, 40, UI_POS_FREE, main_renderer); | |
// sets the input field to be at the center of the screen | |
ui_input_field_set_pos (input, NULL, UI_POS_MIDDLE_CENTER, main_renderer); | |
// sets the placeholder text for the input field and some of its style attributes | |
ui_input_field_placeholder_text_set (input, main_renderer, "Search", font, 24, RGBA_WHITE); | |
ui_input_field_placeholder_text_pos_set (input, UI_POS_MIDDLE_CENTER); | |
// it is important to initialize the text method to be empty | |
ui_input_field_text_set (input, main_renderer, "", font, 24, RGBA_WHITE, false); | |
ui_input_field_text_pos_set (input, UI_POS_MIDDLE_CENTER); | |
// sets the input to have a white outline | |
ui_input_field_ouline_set_colour (input, RGBA_WHITE); | |
// sets an action to be executed on every stroke, like a search method | |
// ui_input_field_set_on_key_input (input, media_search, input); | |
// sets the input to be on the top layer | |
ui_element_set_layer (main_renderer->ui, input->ui_element, "top"); | |
// ui_element_toggle_active (input->ui_element); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment