LegacyScriptEngine icon indicating copy to clipboard operation
LegacyScriptEngine copied to clipboard

[Bug]: mc.newSimpleForm() addLabel 添加的是按钮而不是文本

Open zmsgsb opened this issue 4 months ago • 3 comments

Describe the bug

Image

mc.newSimpleForm() addLabel 添加的是按钮而不是文本

To Reproduce

在 mc.newSimpleForm() 中 使用 addLabel

Expected behavior

mc.newSimpleForm() addLabel 添加的是文本而不是按钮

Screenshots

No response

Platform

win10

BDS Version

1.21.93

LeviLamina Version

1.4.2

LegacyScriptEngine Version

0.13.1

Additional context

No response

zmsgsb avatar Jul 27 '25 05:07 zmsgsb

Image

zmsgsb avatar Jul 27 '25 05:07 zmsgsb

https://github.com/LiteLDev/LegacyScriptEngine/blob/68ae503cf0293f04ec1d1a2fc8f4451b59d74664/src/legacy/api/GuiAPI.cpp#L134-L143

额,没错啊,是 appendLabel

engsr6982 avatar Jul 27 '25 05:07 engsr6982

LegacyScriptEngine/src/legacy/api/GuiAPI.cpp

Lines 134 to 143 in 68ae503

Local<Value> SimpleFormClass::addLabel(const Arguments& args) { CHECK_ARGS_COUNT(args, 1); CHECK_ARG_TYPE(args[0], ValueKind::kString);

 try { 
     form.appendLabel(args[0].asString().toString()); 
     return this->getScriptObject(); 
 } 
 CATCH("Fail in addLabel!") 

} 额,没错啊,是 appendLabel

大错特错:代码写的是 addLabel 但是实际上是按钮

function sendTestForm(player) {
    const form = mc.newSimpleForm();
    form.setTitle("测试表单标题");
    form.setContent(`测试表单内容`);
    form.addLabel(`测试表单文本1`);
    form.addLabel(`测试表单文本2`);
    form.addLabel(`测试表单文本3`);
    player.sendForm(form, (pl, id) => {
        if (id == null) return;
    });
}
mc.regPlayerCmd("testform", "发送测试表单", (player, args) => {
    sendTestForm(player);
})

zmsgsb avatar Jul 28 '25 02:07 zmsgsb