REVIEWED: GuiDropdownBox() locking mechanism #139

This commit is contained in:
raysan5 2021-10-05 11:23:58 +02:00
parent 734d067335
commit 2bb3e17c1e
2 changed files with 7 additions and 8 deletions

View File

@ -22,15 +22,15 @@
* *
* *
* DEPENDENCIES: * DEPENDENCIES:
* raylib 2.6-dev - Windowing/input management and drawing. * raylib 4.0 - Windowing/input management and drawing.
* raygui 2.6-dev - Immediate-mode GUI controls. * raygui 3.0 - Immediate-mode GUI controls.
* *
* COMPILATION (Windows - MinGW): * COMPILATION (Windows - MinGW):
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99 * gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
* *
* Copyright (c) 2020 Ramon Santamaria (@raysan5) * Copyright (c) 2016-2021 Ramon Santamaria (@raysan5)
* *
**********************************************************************************************/ **********************************************************************************************/
@ -145,6 +145,7 @@ int main()
// raygui: controls drawing // raygui: controls drawing
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (dropDown000EditMode || dropDown001EditMode) GuiLock(); if (dropDown000EditMode || dropDown001EditMode) GuiLock();
else if (!dropDown000EditMode && !dropDown001EditMode) GuiUnlock();
//GuiDisable(); //GuiDisable();
// First GUI column // First GUI column
@ -163,13 +164,13 @@ int main()
if (GuiButton((Rectangle){ 25, 255, 125, 30 }, GuiIconText(RICON_FILE_SAVE, "Save File"))) showTextInputBox = true; if (GuiButton((Rectangle){ 25, 255, 125, 30 }, GuiIconText(RICON_FILE_SAVE, "Save File"))) showTextInputBox = true;
GuiGroupBox((Rectangle){ 25, 310, 125, 150 }, "STATES"); GuiGroupBox((Rectangle){ 25, 310, 125, 150 }, "STATES");
GuiLock(); //GuiLock();
GuiSetState(GUI_STATE_NORMAL); if (GuiButton((Rectangle){ 30, 320, 115, 30 }, "NORMAL")) { } GuiSetState(GUI_STATE_NORMAL); if (GuiButton((Rectangle){ 30, 320, 115, 30 }, "NORMAL")) { }
GuiSetState(GUI_STATE_FOCUSED); if (GuiButton((Rectangle){ 30, 355, 115, 30 }, "FOCUSED")) { } GuiSetState(GUI_STATE_FOCUSED); if (GuiButton((Rectangle){ 30, 355, 115, 30 }, "FOCUSED")) { }
GuiSetState(GUI_STATE_PRESSED); if (GuiButton((Rectangle){ 30, 390, 115, 30 }, "#15#PRESSED")) { } GuiSetState(GUI_STATE_PRESSED); if (GuiButton((Rectangle){ 30, 390, 115, 30 }, "#15#PRESSED")) { }
GuiSetState(GUI_STATE_DISABLED); if (GuiButton((Rectangle){ 30, 425, 115, 30 }, "DISABLED")) { } GuiSetState(GUI_STATE_DISABLED); if (GuiButton((Rectangle){ 30, 425, 115, 30 }, "DISABLED")) { }
GuiSetState(GUI_STATE_NORMAL); GuiSetState(GUI_STATE_NORMAL);
GuiUnlock(); //GuiUnlock();
comboBoxActive = GuiComboBox((Rectangle){ 25, 470, 125, 30 }, "ONE;TWO;THREE;FOUR", comboBoxActive); comboBoxActive = GuiComboBox((Rectangle){ 25, 470, 125, 30 }, "ONE;TWO;THREE;FOUR", comboBoxActive);
@ -228,8 +229,6 @@ int main()
strcpy(textInput, "\0"); strcpy(textInput, "\0");
} }
} }
GuiUnlock();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
EndDrawing(); EndDrawing();

View File

@ -1895,7 +1895,7 @@ bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMo
// Update control // Update control
//-------------------------------------------------------------------- //--------------------------------------------------------------------
if ((state != GUI_STATE_DISABLED) && !guiLocked && (itemCount > 1)) if ((state != GUI_STATE_DISABLED) && (editMode || !guiLocked) && (itemCount > 1))
{ {
Vector2 mousePoint = GetMousePosition(); Vector2 mousePoint = GetMousePosition();