tips
[Top] [All Lists]

Making the Return and Enter keys work the same in editfields

To: "REALbasic Tips" <REALbasic-tips at lists dot realsoftware dot com>
Subject: Making the Return and Enter keys work the same in editfields
From: Geoff Perlman <geoff at realsoftware dot com>
Date: Wed, 02 Feb 2000 09:13:57 -0600
The Return and Enter keys are not the same though they commonly work the
same way. But while pressing the Return key in multi-line editfield adds a carriage return, pressing the Enter key adds an Enter character (ascii 3).
In many cases the desired behavior would be to have the Enter key add a
carriage return just like the Return. Fortunately, making this happen is a
simple matter. In the keydown event of the editfield, you simply need to
check for the enter key and return false from the keydown event to filter
the keystroke then insert a carriage return. The code to do this in the
editfield keydown event looks like this:

if asc(key) = 3 then
me.seltext = chr(13)
return true
end if
--

Geoff Perlman
REAL Software, Inc.
http://www.realsoftware.com
mailto:geoff at realsoftware dot com



 - - - - - - - - - -
For list commands, send "Help" in the body of a message to
<requests at lists dot realsoftware dot com>



<Prev in Thread] Current Thread [Next in Thread>
  • Making the Return and Enter keys work the same in editfields, Geoff Perlman <=