Search code examples
livecode

How to select a word with special characters in LIvecode


How to select a word with with special characters (eg: usa-uk). the following code will select text but it's doesn't select the words like usa-uk. How I change my code

select the mouseText 

Solution

  • If you don't have a huge text in your field you might use:

    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