소스 검색

REVIEWED: `GuiCheckBox()` #330

return internal-state: 1->Value changed in the control
Ray 2 년 전
부모
커밋
1c3305031d
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  1. 6 2
      src/raygui.h

+ 6 - 2
src/raygui.h

@@ -2189,7 +2189,7 @@ int GuiToggleSlider(Rectangle bounds, const char *text, int *active)
     return result;
     return result;
 }
 }
 
 
-// Check Box control, returns true when active
+// Check Box control, returns 1 when state changed
 int GuiCheckBox(Rectangle bounds, const char *text, bool *checked)
 int GuiCheckBox(Rectangle bounds, const char *text, bool *checked)
 {
 {
     int result = 0;
     int result = 0;
@@ -2228,7 +2228,11 @@ int GuiCheckBox(Rectangle bounds, const char *text, bool *checked)
             if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
             if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = STATE_PRESSED;
             else state = STATE_FOCUSED;
             else state = STATE_FOCUSED;
 
 
-            if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) *checked = !(*checked);
+            if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
+            {
+                *checked = !(*checked);
+                result = 1;
+            }
         }
         }
     }
     }
     //--------------------------------------------------------------------
     //--------------------------------------------------------------------