bug: Side-specific border coloring with .xml values does not work #47

Open
opened 2023-02-20 13:37:59 +08:00 by Felipe-Caldeira · 1 comment
Felipe-Caldeira commented 2023-02-20 13:37:59 +08:00 (Migrated from github.com)

Describe the bug

Side-specific border coloring when making the UI with .xml does not work properly.

To Reproduce

Steps to reproduce the behavior:

  1. Create a simple Basalt UI with .xml style
  2. Add an object with a side-specific border coloring:
<button x="2" y="2" text="Hello" borderBottom="blue" />
  1. Run the program
  2. See error:
    Basalt error: .../basaltDraw.lua:202: bad argument (string expected, got nil)

Expected behavior

A button with the text "Hello" should appear with a blue border only along the bottom

Additional context

Changing these four lines (138-141) in Object.lua seems to fix it! Just had to wrap the xmlValue(...) return with colors[...], like the other surrounding code does.

if(xmlValue("borderLeft", data)~=nil)then borderColors["left"] = colors[xmlValue("borderLeft", data)] end
if(xmlValue("borderTop", data)~=nil)then borderColors["top"] = colors[xmlValue("borderTop", data)] end
if(xmlValue("borderRight", data)~=nil)then borderColors["right"] = colors[xmlValue("borderRight", data)] end
if(xmlValue("borderBottom", data)~=nil)then borderColors["bottom"] = colors[xmlValue("borderBottom", data)] end

Checklist

[x] I am running the latest version.
Tick the box if you are running the latest version!

**Describe the bug** Side-specific border coloring when making the UI with .xml does not work properly. **To Reproduce** Steps to reproduce the behavior: 1. Create a simple Basalt UI with .xml style 2. Add an object with a side-specific border coloring: ```xml <button x="2" y="2" text="Hello" borderBottom="blue" /> ``` 4. Run the program 5. See error: `Basalt error: .../basaltDraw.lua:202: bad argument (string expected, got nil)` **Expected behavior** A button with the text "Hello" should appear with a blue border only along the bottom **Additional context** Changing these four lines (138-141) in `Object.lua` seems to fix it! Just had to wrap the `xmlValue(...)` return with `colors[...]`, like the other surrounding code does. ```lua if(xmlValue("borderLeft", data)~=nil)then borderColors["left"] = colors[xmlValue("borderLeft", data)] end if(xmlValue("borderTop", data)~=nil)then borderColors["top"] = colors[xmlValue("borderTop", data)] end if(xmlValue("borderRight", data)~=nil)then borderColors["right"] = colors[xmlValue("borderRight", data)] end if(xmlValue("borderBottom", data)~=nil)then borderColors["bottom"] = colors[xmlValue("borderBottom", data)] end ``` **Checklist** [x] I am running the latest version. Tick the box if you are running the latest version!
NoryiE commented 2023-02-20 23:31:32 +08:00 (Migrated from github.com)

Hello! Thank you very much - also thanks for fixing it yourself and providing me the code! This issue got fixed in 6f0ddd6.

Hello! Thank you very much - also thanks for fixing it yourself and providing me the code! This issue got fixed in [6f0ddd6](https://github.com/Pyroxenium/Basalt/commit/6f0ddd6bf6041a0adda1ecc57e64b87643936522).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: GitHub/Basalt#47
No description provided.