REVIEW: GuiTextInputBox()

This commit is contained in:
raysan5
2019-08-10 13:12:40 +02:00
parent 2ecc35ba05
commit 7e971886b0
3 changed files with 23 additions and 6 deletions

View File

@ -103,6 +103,8 @@ int main()
char textInput[256] = { 0 };
bool showTextInputBox = false;
char textInputFileName[256] = { 0 };
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -213,12 +215,21 @@ int main()
if (showTextInputBox)
{
char textInputTemp[256] = { 0 };
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, 0.8f));
int result = GuiTextInputBox((Rectangle){ GetScreenWidth()/2 - 120, GetScreenHeight()/2 - 60, 240, 120 }, GuiIconText(RICON_FILE_SAVE, "Save file as..."), textInputTemp, "Ok;Cancel");
int result = GuiTextInputBox((Rectangle){ GetScreenWidth()/2 - 120, GetScreenHeight()/2 - 60, 240, 120 }, GuiIconText(RICON_FILE_SAVE, "Save file as..."), textInput, "Ok;Cancel");
if ((result == 0) || (result == 2)) showTextInputBox = false;
else if (result == 1) strcpy(textInput, textInputTemp);
if (result == 1)
{
// TODO: Validate textInput value and save
strcpy(textInputFileName, textInput);
}
if ((result == 0) || (result == 1) || (result == 2))
{
showTextInputBox = false;
strcpy(textInput, "\0");
}
}
GuiUnlock();

View File

@ -115,7 +115,7 @@ typedef struct FileInfo {
static char **ReadDirectoryFiles(const char *dir, int *filesCount, char *filterExt);
// List View control for files info with extended parameters
static int GuiListViewFiles(Rectangle bounds, const char **text, int count, int *focus, int *scrollIndex, int active)
static int GuiListViewFiles(Rectangle bounds, const char **text, int count, int *focus, int *scrollIndex, int active);
//static int GuiListViewFiles(Rectangle bounds, FileInfo *files, int count, int *focus, int *scrollIndex, int active)
//----------------------------------------------------------------------------------