Problems Getting Keyboard Event From text-area
Posted: Mon Dec 07, 2015 11:41 pm
Hi!
I'm trying to wire up a text-area with a keyboard event so I can detect if the user presses the escape key while typing. It works fine for text-field Title (see below), but the handler never gets called for keypresses in Body. I have wired the standard handler into gs:no-action because it either only gets fired on pressing the enter key (text-field) or doesn't have any information about non-textual keys (text-area).
Can anyone point out where I'm going wrong?
Thanks!
I'm trying to wire up a text-area with a keyboard event so I can detect if the user presses the escape key while typing. It works fine for text-field Title (see below), but the handler never gets called for keypresses in Body. I have wired the standard handler into gs:no-action because it either only gets fired on pressing the enter key (text-field) or doesn't have any information about non-textual keys (text-area).
Can anyone point out where I'm going wrong?
Thanks!
Code: Select all
(load (append (env "NEWLISPDIR") "/guiserver.lsp"))
(gs:init)
(define (field-key id type code modifiers)
"( id type code modifiers --) Handler for keyboard."
(println "Key for " id " " type ", " code " with " modifiers "."))
(define (layout)
"( --) Layout GUI."
(gs:text-field 'Title 'gs:no-action 64)
(gs:key-event 'Title 'field-key)
(gs:text-area 'Body 'gs:no-action)
(gs:key-event 'Body 'field-key)
(gs:frame 'F 0 0 800 600 "Text Keyboard Event Test")
(gs:set-border-layout 'F)
(gs:add-to 'F 'Title "north" 'Body "center")
(gs:set-visible 'F true))
(layout)
(gs:listen)