Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple GuiTextInputBox() not supported #372

Closed
Anut-py opened this issue Jan 28, 2024 · 2 comments
Closed

Multiple GuiTextInputBox() not supported #372

Anut-py opened this issue Jan 28, 2024 · 2 comments

Comments

@Anut-py
Copy link
Contributor

Anut-py commented Jan 28, 2024

Compile and run the following code

#include <raylib.h>

#define RAYGUI_IMPLEMENTATION
#include <raygui.h>
#undef RAYGUI_IMPLEMENTATION

int main(void) {
    InitWindow(800, 500, "test");
    SetTargetFPS(60);
    GuiEnable();
    GuiUnlock();

    Rectangle bounds = { 10, 40, 400, 150 };
    Rectangle bounds1 = { 10, 200, 400, 150 };

    char *buffer = calloc(1024, sizeof(char));
    strcpy(buffer, "Hello world");

    char *buffer1 = calloc(1024, sizeof(char));
    strcpy(buffer1, "password");

    bool secret = true;

    while (!WindowShouldClose()) {
        BeginDrawing();
        ClearBackground(RAYWHITE);
        
        GuiTextInputBox(bounds, 0, "Hello", "A;B;C;D", buffer, 1024, 0);
        GuiTextInputBox(bounds1, 0, "Password", "E;F;G;H", buffer1, 1024, &secret);

        EndDrawing();
    }

    CloseWindow();
}

Editing one text box affects the other and sometimes they don't edit at all.

@raysan5
Copy link
Owner

raysan5 commented Jan 28, 2024

@Anut-py Yes, it is. This control was designed to have only one of it on the screen, actually it was a simple replace for native desktop dialogs for systems not supporting them (i.e. embedded devices running raylib in headless mode).

Here it is an usage sample:

// GUI: Save File Dialog (and saving logic)
//----------------------------------------------------------------------------------------
if (showSaveFileDialog)
{
#if defined(CUSTOM_MODAL_DIALOGS)
    //int result = GuiFileDialog(DIALOG_TEXTINPUT, "Save raygui icons file...", outFileName, "Ok;Cancel", NULL);
    int result = GuiTextInputBox((Rectangle){ screenWidth/2 - 280/2, screenHeight/2 - 112/2 - 30, 280, 112 }, "#2#Save rtool config file...", NULL, "#2#Save", outFileName, 512, NULL);
#else
    int result = GuiFileDialog(DIALOG_SAVE_FILE, "Save rtool config file...", outFileName, "*.rtool", "rTool Config (*.rtool)");
#endif
    if (result == 1)
    {
        // Check for valid extension and make sure it is
        if ((GetFileExtension(outFileName) == NULL) || !IsFileExtension(outFileName, ".rtool")) strcat(outFileName, ".rtool\0");

        SaveToolConfig(rtool, outFileName);   // Save rtool config file
    }

    if (result >= 0) showSaveFileDialog = false;
}
//----------------------------------------------------------------------------------------

It should probably be redesigned/improved.

@raysan5 raysan5 changed the title Using multiple GuiTextInputBoxes is buggy Multiple GuiTextInputBox() not supported May 7, 2024
@raysan5
Copy link
Owner

raysan5 commented May 7, 2024

I'm closing this issue "as design" for now. The control was actually designed to only allow one of them on screen at a time.

@raysan5 raysan5 closed this as completed May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants