0

I want to highlight the strings before and after '--'. Example good -- bad here i want to highlight good and bad. when ever the -- is comes then before and after the strings are become highlight. Is it possible.

4

1 回答 1

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

当然,您可以在两个“set”语句中使用任何有效的文本块表达式,具体取决于您要“突出显示”“--”之前和之后的文本部分。

要从字段中清除背景颜色,请执行以下操作:

set the backgroundColor of char 1 to -1 of fld "mytext" to empty
于 2015-04-09T16:32:36.203 回答