Text 如何在LiveCode中设置字段内容的文本样式属性

Text 如何在LiveCode中设置字段内容的文本样式属性,text,properties,field,livecode,Text,Properties,Field,Livecode,我的LiveCode应用程序中有一个滚动字段,如下所示: A:约翰·罗杰斯234 B:Henry Ford 555 1st C:Jane Fonda 224 5 我想让每行中的最后一个单词(即第9、1、5位)具有特定的文本样式。例如,使其颜色为红色 我尝试了几种方法,包括使用此代码迭代行: repeat for each line lC in field "fcontent" set the foregroundColor of lC to "red" end repeat …但

我的LiveCode应用程序中有一个滚动字段,如下所示:

A:约翰·罗杰斯234 B:Henry Ford 555 1st
C:Jane Fonda 224 5

我想让每行中的最后一个单词(即第9、1、5位)具有特定的文本样式。例如,使其颜色为红色

我尝试了几种方法,包括使用此代码迭代行:

repeat for each line lC in  field "fcontent"  
  set the foregroundColor of lC to "red"  
end repeat

…但总是出错。请有人把我带到正确的轨道上来?

您使用foreGroundColor的解决方案几乎是正确的。您需要改为使用textColor,在这种情况下,不能对每个控件结构使用repeat

repeat with x = 1 to the number of lines of fld "fcontent"
  set the textColor of the last word of line x of fld "fcontent" to red
end repeat

红色不需要引号,因为它在LiveCode中定义为常量。

使用foreGroundColor的解决方案几乎是正确的。您需要改为使用textColor,在这种情况下,不能对每个控件结构使用repeat

repeat with x = 1 to the number of lines of fld "fcontent"
  set the textColor of the last word of line x of fld "fcontent" to red
end repeat

红色不需要引号,因为它在LiveCode中定义为常量。

标记解决方案是正确的。看看你的问题,你提到要设置每行最后一个单词的颜色。您可以在Mark的脚本中添加“最后一句话”,您应该得到您想要的:

repeat with x = 1 to the number of lines of fld "fcontent"
   set the textColor of the last word of line x of fld "fcontent" to "255,0,100"
end repeat

马克的解决方案是正确的。看看你的问题,你提到要设置每行最后一个单词的颜色。您可以在Mark的脚本中添加“最后一句话”,您应该得到您想要的:

repeat with x = 1 to the number of lines of fld "fcontent"
   set the textColor of the last word of line x of fld "fcontent" to "255,0,100"
end repeat

但是为什么“repeat for each”结构在这里不起作用呢?repeat foreach循环中的LC变量是字符串,而不是块引用。块引用的形式是“卡c的字段z的x到y行”,而字符串实际上只是字符串(“第9”、“第1”和“第5”)。因此,您可以设置块引用的textColor,但不能设置字符串的textColor。。。这不是你的,而是dtechplus的。谢谢Mark。但是为什么“repeat for each”结构在这里不起作用呢?repeat foreach循环中的LC变量是字符串,而不是块引用。块引用的形式是“卡c的字段z的x到y行”,而字符串实际上只是字符串(“第9”、“第1”和“第5”)。因此,您可以设置块引用的textColor,但不能设置字符串的textColor。。。这不是你的,而是dtechplus的。谢谢,马克。谢谢你,伙计。我在发布代码时不知何故省略了“最后一句话”。但我现在知道我的主要错误是没有意识到我必须使用textColor而不是foregroundColor!是 啊谢谢你,伙计。我在发布代码时不知何故省略了“最后一句话”。但我现在知道我的主要错误是没有意识到我必须使用textColor而不是foregroundColor!