[Openmcl-devel] Key Codes in OpenMCL

Gary Byers gb at clozure.com
Sun Jan 14 15:03:35 PST 2007



On Sat, 13 Jan 2007, Brent Fulgham wrote:

> I'm attempting to port some code that made use of MCL's key handling
> logic:
>
> (defmethod VIEW-KEY-EVENT-HANDLER ((Self Window) Key)
>   (let ((Delta 0.01))
>     (case Key
>       (#\ForwardArrow (incf (cursor-x Self) Delta))
>       (#\BackArrow (decf (cursor-x Self) Delta))
>       (#\UpArrow (incf (cursor-y Self) Delta))
>       (#\DownArrow (decf (cursor-y Self) Delta))
>       (#\space ...
>       (#\+
>       (#\-
>            ... etc ...
>  )))
>
> Many of the necessary key codes are already available:
>
> ? #\space
> #\
> ? #\+
> #\+
> ? #\newline
> #\Newline
> ? #\linefeed
> #\Newline
> ? #\return
> #\Return
>
> However, the arrow keys (and some function keys) are not defined:

Would it be appropriate to give characters whose CHAR-CODEs match
the key codes returned by Carbon event primitives names which reflect
the keys which typically generate those events ?

I don't think so, but it sounds like there are at least a few cases of
this leftover.  (E.g., the original circa 1985 MacPlus keyboard didn't
have an escape key but did have a "clear" key thay generated code 27,
and someone - I doubt if it was me, but it was ~20 years ago - decided
what it made sense for "clear" to be a name for the character whose
CHAR-CODE was 27.)

There's some (often high) correlation between Carbon event key codes and
CHAR-CODEs, but they're really different namespaces.

Cocoa uses a private-use range of the Unicode code space (#\uf700-#\uf8ff)
to name characters produced by function keys.  Giving the character whose
code is #xf700 (= #$NSUpArrowFunctionKey) a name like "NSUpArrowFunctionKey"
might make a little bit of sense, since there's at least some context
in which #xf700 is used as a character code (e.g., in the NSString
returned by -[NSEvent characters].

And yes: there should be some user-visible way of naming characters.
(What's there now isn't thread-safe - just intended to run in the
initial thread during the cold load - and isn't opaque enough.)
I don't think that such a mechanism should be used to confuse Carbon
event codes with CHAR-CODEs.

>
> ? #\delete
> #\Backspace
> ? #\clear
> #\ESC#\f1
> ? #\uparrow
>
> > Error: Unknown character name - "uparrow" .
> > While executing: #<Anonymous Function #x81CFAF6>, in process
> listener(1).
> > Type :POP to abort, :R for a list of available restarts.
> > Type :? for other options.
> 1 > #\UpArrow
>
> The only thing I can find in the source tree related to the cursor
> keys are some hemlock-specific binding functions:
>
> hemlock/src/bindings.lisp:(bind-key "Previous Line" #k"uparrow")
> hemlock/unused/keytrandefs.lisp:(define-keysym 65362 #\uparrow #\s-
> uparrow)
>
> How can I create my own identifiers for characters?
>
> Thanks,
>
> -Brent
>
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>



More information about the Openmcl-devel mailing list