瀏覽代碼

Store secret text as static variable (#195)

When compiling with Zig, the old implementation
raises this error:

```
error: expected type '[*c]u8', found '*const [16:0]u8'
note: cast discards const qualifier
```

As it does not allow casting away the const qualifier,
we need to store the "********" placeholder in a writable
variable.

Co-authored-by: Fabien Freling <[email protected]>
Fabien Freling 3 年之前
父節點
當前提交
c4e121d548
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      src/raygui.h

+ 2 - 1
src/raygui.h

@@ -3151,8 +3151,9 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co
 
     if (secretViewActive != NULL)
     {
+        static char stars[] = "****************";
         if (GuiTextBox(RAYGUI_CLITERAL(Rectangle){ textBoxBounds.x, textBoxBounds.y, textBoxBounds.width - 4 - RAYGUI_TEXTINPUTBOX_HEIGHT, textBoxBounds.height }, 
-            ((*secretViewActive == 1) || textEditMode)? text : (char *) "****************", textMaxSize, textEditMode)) textEditMode = !textEditMode;
+            ((*secretViewActive == 1) || textEditMode)? text : stars, textMaxSize, textEditMode)) textEditMode = !textEditMode;
 
         *secretViewActive = GuiToggle(RAYGUI_CLITERAL(Rectangle){ textBoxBounds.x + textBoxBounds.width - RAYGUI_TEXTINPUTBOX_HEIGHT, textBoxBounds.y, RAYGUI_TEXTINPUTBOX_HEIGHT, RAYGUI_TEXTINPUTBOX_HEIGHT }, (*secretViewActive == 1)? "#44#" : "#45#", *secretViewActive);
     }