0

「--」の前後の文字列を強調表示したい。例 良い -- 悪い ここでは、良い点と悪い点を強調したいと思います。-- が来るたびに、文字列の前後が強調表示されます。出来ますか。

4

1 に答える 1

0

フィールド「mytext」に次のテキストがあるとします。

This text comes before -- this text comes after.

LiveCode (ほとんどのアプリケーションと同様) は不連続な選択を許可しないため、'select' コマンドは連続したテキストに対してのみ機能します。

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

もちろん、「ハイライト」したい " -- " の前後のテキストの部分に応じて、2 つの 'set' ステートメントで任意の有効なテキスト チャンク式を使用できます。

フィールドから backgroundColor をクリアするには、次のようにします。

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