news
About Elegant Chaos
info
About me and my friends
people
Software from Elegant Chaos
software
Other stuff...
stuff

UL_SmartQuote

Revision
Revised on

Description

Handle quote characters intelligently. Takes the character to be handled.

This routine can be used to implement "smart" quote characters in text fields. This is done by putting the script

on keyDown k UL_SmartQuote k end keyDown

into the field.

With the above script in a field, when


Code

on UL_SmartQuote key
  get the selectedChunk
  subtract 1 from word 2 of it
  delete word 3 to 4 of it
  put value(it) into lastKey
  
  if key is "'" then
    put "'" into key
    
  else if key is quote then
    if (lastKey is space) or (lastKey is return) then
      put """ into key
    else
      put """ into key
    end if
    
  else if key is """ then
    put quote into key
    
  else if key is "'" then
    put "'" into key
  end if
  
  keydown key
  
  
end UL_SmartQuote