Page 1 of 1

the "backspacekey" and "keyup" handlers as wrappers

Posted: Thu Jul 03, 2014 9:11 am
by chrisw
Hallo,

what is false in that script, especially in line 2 of it (if thekey...)?

on keyup
if thekey = "backspacekey" then
delete last char of fld 16
delete last char of fld 12
else
if (lineoffset(" " & fld 12,fld 1 of stack "wbuch")) = 0 then
delete last char of fld 12 of stack "wbuch"
delete last char of fld 16 of stack "wbuch"
end if
end if
end keyup

Thanks for any hint.

chrisw

Re: the "backspacekey" and "keyup" handlers as wrappers

Posted: Thu Jul 03, 2014 9:19 am
by jmburnod
Hi Chris,
check "rawkeyup" in the LC dictionary.
Best regards
Jean-Marc

Re: the "backspacekey" and "keyup" handlers as wrappers

Posted: Thu Jul 03, 2014 11:39 am
by Klaus
Hi Chris,

waht Jean-Marc said AND you forgot the parameter in your "keyup" handler: on keyup THEKEY

Best

Klaus

Re: the "backspacekey" and "keyup" handlers as wrappers

Posted: Thu Jul 03, 2014 3:29 pm
by chrisw
Thank You very much!
But how it should be:

on keyup thekey
if it = backspacekey then...

that does not work!

best reagards,

chrisw

Re: the "backspacekey" and "keyup" handlers as wrappers

Posted: Thu Jul 03, 2014 3:32 pm
by Klaus
Hi Chris,

because "backspacekey" has its own message:

Code: Select all

on backspacekey
   ## do this or that
   PASS backspacekey
   ## or not!
end backspacekey
:D

Best

Klaus

Re: the "backspacekey" and "keyup" handlers as wrappers

Posted: Thu Jul 03, 2014 4:24 pm
by chrisw
hallo, Klaus,

ind the fld-script i had

on backspacekey and on keyup

in "backspacekey" were the two lines

in "Keyup" the rest.

That does not work, because the command "delete last char" is also in the keyup. So pass backspacekey or not does not work. I ended backspacekey with "exit to top" - but that did not help either.

I was told:
In the way your code example is structured, you could set a flag that indicates when a "backspacekey" was handled. This could be reset when the "keyup" handler is called.

Alternatively you could use the "backspacekey" and "keyup" handlers as wrappers that call a particular function or command. The arguments you pass in could then inform that section of code what to do.

but indeed: I do not know how to formulate that. I am quite desperate!

Best

chrisw

Re: the "backspacekey" and "keyup" handlers as wrappers

Posted: Thu Jul 03, 2014 5:29 pm
by Klaus
Hi Chris,

"backspacekey" and also "deletekey" are MESSAGES, so they will never appear in the parameter-> theKey in the keyup handler!
These can only be "trapped" with checking "rawkeyup" as Jean-Marc suggested!

So what did you finally script?


Best

Klaus

Re: the "backspacekey" and "keyup" handlers as wrappers

Posted: Thu Jul 03, 2014 5:59 pm
by jmburnod
Hi Chris,
Try this:

Code: Select all

on rawkeyup pKey
   put pKey
end rawkeyup
Best regards
Jean-Marc

Re: the "backspacekey" and "keyup" handlers as wrappers

Posted: Fri Jul 04, 2014 8:10 am
by chrisw
Hi Jean-Marc and Klaus,

(put pkey (= backspacekey) = 65288)

on rawkeyup pKey
if pKey = 65288 then
delete last char of fld 16
delete last char of fld 12
--exit to top
else
if (lineoffset(" " & fld 12,fld 1 of stack "wbuch")) = 0 then
delete last char of fld 12 of stack "wbuch"
delete last char of fld 16 of stack "wbuch"
end if
end if
end rawkeyup

the result is:
in fld 16 the last two chars are deleted
in fld 12 the last char


amazingly:
on rawkeyup pKey
if pKey = 65288 then
delete last char of fld 16
delete last char of fld 12
end if
end rawkeyup

brings the same effect!

would it help, if I send You the whole stack?

Best regards,

Chrisw

Re: the "backspacekey" and "keyup" handlers as wrappers

Posted: Sat Jul 05, 2014 6:36 pm
by jmburnod
Hi Chris,
would it help, if I send You the whole stack?
Certainly but you can upload a stack once you have 10 messages posted
Best
Jean-Marc