mirror of
https://github.com/raysan5/raygui.git
synced 2025-12-25 10:22:33 -05:00
REVIEW: GuiTextInputBox()
This commit is contained in:
@ -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();
|
||||
|
||||
@ -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)
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
@ -3714,6 +3714,12 @@ RAYGUIDEF int GuiTextInputBox(Rectangle bounds, const char *windowTitle, char *t
|
||||
#define TEXTINPUTBOX_BUTTON_PADDING 10
|
||||
#define TEXTINPUTBOX_HEIGHT 30
|
||||
|
||||
#define MAX_FILENAME_LENGTH 256
|
||||
|
||||
// Used to enable text edit mode
|
||||
// WARNING: No more than one GuiTextInputBox() should be open at the same time
|
||||
static textEditMode = false;
|
||||
|
||||
int btnIndex = -1;
|
||||
|
||||
int buttonsCount = 0;
|
||||
@ -3734,7 +3740,7 @@ RAYGUIDEF int GuiTextInputBox(Rectangle bounds, const char *windowTitle, char *t
|
||||
//--------------------------------------------------------------------
|
||||
if (GuiWindowBox(bounds, windowTitle)) btnIndex = 0;
|
||||
|
||||
GuiTextBox(textBoxBounds, text, 256, true);
|
||||
if (GuiTextBox(textBoxBounds, text, MAX_FILENAME_LENGTH, textEditMode)) textEditMode = !textEditMode;
|
||||
|
||||
int prevBtnTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT);
|
||||
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER);
|
||||
|
||||
Reference in New Issue
Block a user