[REBOL] Re: Inline edit field
From: brett::codeconscious::com at: 27-Feb-2004 22:20
> reveals the code to do this, and I can't figure out how field captures
> an enter or tab key to unfocus the field, where a textarea sets it to a
> new line. The button behaves the same way. Any ideas?
Focus directs keystroke events to a specific face - the focal face.
When a Field is the focal-face, its Feel object (ctx-text/edit) has an
Engage function which processes Key events - it actually delegates the key
processing to another function (ctx-text/edit-text). The Edit-text function
performs focussing functionality when it receives Enter and Tab keys.
As Ammon pointed out you can intercept key events using an event function.
Alternatively you can use a detect function in any face that contains the
focal-face (the parent-face or the parent of the parent,etc)
For example - here panel intercepts events directed to the box - type some
keys to test it:
view layout [
style testbox box green feel [
engage: func [face action event] [
if event/key [print [face/var event/key]]
]
]
p1: panel feel [
detect: func [face event] [
print [event/type event/key]
event ; Must return the event or None
]
] [ b1: testbox]
do [focus b1]
]
HTH
Brett.