preventing deletion of linefeds

John Craig jc at spl21.net
Wed Dec 6 14:48:16 EST 2006


Viktoras, here's a handler that will stop the backspace and delete keys 
working in a text field.  I hope I understand you correctly, because I 
was struggling to think of a use for this!  Like Jim says, you may want 
to handle the cutKey message, etc. This handler blocks multi line 
selecting  and then a keypress if the selection contains a return character.


on rawKeyDown pCode
  if pCode is not among the items of "65288,65535" then pass rawKeyDown
 
  put word 2 of the selectedChunk into tStart
  put word 4 of the selectedChunk into tEnd
 
  if tStart <= tEnd then
    put char tStart to tEnd of me into tSelection
    if return is not among the chars of tSelection then
      pass rawKeyDown
    end if
  else
    if pCode = 65535 then
      put tStart into tPos
    else
      put tEnd into tPos
    end if
    if char tPos of me <> return then
      pass rawKeyDown
    end if
  end if
end rawKeyDown


JC

Viktoras Didziulis wrote:
> can anybody suggest a simple method to prevent users deleting linefeeds in a
> text field when pressing backspace or delete keys. It should allow deletion
> of any other symbol which is not "return" and should not use table object at
> all. 
>  
> What should be added into the handler below? 
> Chunk expression (word 2 of the selectedchunk) > 1 does not work... 
>  
> on backspaceKey 
> if ??? then 
> pass backspaceKey 
> end if 
> end backspaceKey 
>  
> BW 
> Viktoras
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>   





More information about the use-livecode mailing list