突出显示角色之前和之后 -

时间:2015-04-09 04:46:28

标签: livecode livecoding

我希望在' - '之前和之后突出显示字符串。示例好 - 这里不好我想强调好坏。什么时候 - 来了,然后在弦之前和之后变成高亮。可能吗。

1 个答案:

答案 0 :(得分:0)

我们假设您在字段中有以下文字" mytext":

This text comes before -- this text comes after.

LiveCode(因为大多数应用程序)不允许不连续选择,因此选择'命令仅适用于连续运行的文本。

select word 1 to 3 of fld "mytext"

但您可以通过设置单独文本运行的backgroundColor属性来模拟选择突出显示:

put wordOffset("--",fld "mytext") into tWordIndex
set the backgroundColor of word 1 to tWordIndex - 1 of fld "mytext" to the hiliteColor
set the backgroundColor of word tWordIndex + 1 to -1 of fld "mytext" to the hiliteColor

当然,你可以在两个套装中使用任何有效的文本块表达式。声明,取决于"之前和之后的文本部分。 - "你想"突出显示"。

要从字段中清除backgroundColor,请执行以下操作:

set the backgroundColor of char 1 to -1 of fld "mytext" to empty
相关问题