如何在LIvecode中选择带有特殊字符的单词

时间:2015-06-22 09:18:00

标签: livecode

如何选择带有特殊字符的单词(例如:usa-uk)。以下代码将选择文本,但它不会选择像usa-uk这样的单词。我如何更改代码

select the mouseText 

2 个答案:

答案 0 :(得分:0)

你是如何选择的?例如,如果这是在字段脚本中:

on mousemove select the mouseText end mouse move

您将选择光标下的文本。为了选择复合文本,例如“usa-uk”,您必须将该文本片段分组。这会将该片段的textStyle设置为“link”。

克雷格纽曼

答案 1 :(得分:0)

如果您的字段中没有大字,则可以使用:

on mouseMove
   if the mouseLoc is within the rect of me then
      put the mouseChunk into tChunk
      # Check if chars before or after is a "spacing char"
      put word 2 of tChunk into tstart
      put word 4 of tChunk into tEnd
      repeat with i = tStart down to 1 step -1
         if matchText(char i of me, "\s") then exit repeat
      end repeat
      put i+1 into tStart
      repeat with i = tEnd to the number of chars of me
         if matchText(char i of me, "\s") then exit repeat
      end repeat
      put i-1 into tEnd
      select char tstart to tEnd of me
   end if
end mouseMove