gpt4 book ai didi

label - 长标签文本中的换行

转载 作者:行者123 更新时间:2023-12-01 12:52:59 27 4
gpt4 key购买 nike

有什么技巧可以破坏标签文本吗?因为 '\n' '\r' '\n\r' 不起作用。非常感谢

最佳答案

如果你使用那些 2 parameters你做你想做的不是吗?

app.createLabel(text).setWidth(width).setWordWrap(true)

这是一个示例(在其他小部件中;-):

function showurl() {
var app = UiApp.createApplication();
app.setTitle("Anchor in a popup ;-)");
var panel = app.createFlowPanel()
var image = app.createImage('https://sites.google.com/site/appsscriptexperiments/home/photo.jpg').setPixelSize(50, 50)
var link = app.createAnchor('This is your link', 'https://sites.google.com/site/appsscriptexperiments/home');
var lab = app.createLabel("wrap it because it's too narrow").setWidth(90).setWordWrap(true);
var quit = app.createButton('quit');
panel.add(image).add(link).add(lab).add(quit);
app.add(panel);
var doc = SpreadsheetApp.getActive();
doc.show(app);
}

编辑:我找到了一个 old post (在 Google 群组论坛上,再次感谢 Henrique ;-) 关于 toast 消息中的断行,这是我在这种情况下使用的代码......该原则也适用于标签,但我没有尝试。要使用它,只需在包含您的文本的变量中使用\n(您想要换行的地方)并将其传递给此函数。 (脚本中有注释说明)

function break_(msg){
var temp = escape(msg);// shows codes of all chars
msg = unescape(temp.replace(/%20/g,"%A0")); // replace spaces by non break spaces
temp = msg.replace("\n"," "); // and replace the 'newline' by a normal space
return temp; // send back the result
}

关于label - 长标签文本中的换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11145656/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com