key event
[1/3] from: hijim::pronet::net at: 8-Jul-2002 18:10
It turns out that remove system/view/screen-face/feel/event-funcs messes up request-file.
Is there a way to keep get the caret positiopn whenever any key is pressed?
I used the following to get the caret position when I press Escape.
key #"^[" [pos: copy system/view/caret]
I can then make a button with this code:
but "z" [
focus my-area
system/view/caret: find my-area/text pos
put "Z" 1
]
Now I can reclaim focus and the caret position when I click the button.
The put function is:
put: func [str num][
if my-area <> system/view/focal-face [return]
if not system/view/caret [return]
insert system/view/caret str
system/view/caret: skip system/view/caret num
show my-area
]
How can I get [ pos: copy system/view/caret ] to engage whenever any key is pressed?
Is there a way?
Thanks,
Jim
[2/3] from: rotenca:telvia:it at: 9-Jul-2002 10:54
Hi,
> Is there a way to keep get the caret positiopn whenever any key is pressed?
view layout [
field feel [
engage: func [f a e][
if e/type = 'key [
print ["key-pressed" e/key]
print ["caret" system/view/caret]
]
ctx-text/edit/engage f a e
]
]
]
---
Ciao
Romano
[3/3] from: jim:clatfelter at: 11-Jul-2002 18:37
Hello Romano,
Thanks for that code. I used it as below to keep track of the lines and to
keep the area from ever being dirty. That seems to be the key. It only
affects my-area. It doesn't mess with fields or request-file. Finally the
buttons always work, and focus stays on my-area -- since it's never dirty!
I'm going to try to scroll the slider here too -- on each keystroke. I
haven' figured that one out yet.
my-area: area para []
500x490 my-file white white font-name font-fixed wrap
feel [
engage: func [f a e][
if e/type = 'key [
get-lines
]
ctx-text/edit/engage f a e
my-area/dirty?: false
]
]
Ciao and thanks,
Jim