the "backspacekey" and "keyup" handlers as wrappers

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
chrisw
Posts: 11
Joined: Thu Jul 03, 2014 8:45 am

the "backspacekey" and "keyup" handlers as wrappers

Post by chrisw » Thu Jul 03, 2014 9:11 am

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

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

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

Post by jmburnod » Thu Jul 03, 2014 9:19 am

Hi Chris,
check "rawkeyup" in the LC dictionary.
Best regards
Jean-Marc
https://alternatic.ch

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

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

Post by Klaus » Thu Jul 03, 2014 11:39 am

Hi Chris,

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

Best

Klaus

chrisw
Posts: 11
Joined: Thu Jul 03, 2014 8:45 am

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

Post by chrisw » Thu Jul 03, 2014 3:29 pm

Thank You very much!
But how it should be:

on keyup thekey
if it = backspacekey then...

that does not work!

best reagards,

chrisw

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

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

Post by Klaus » Thu Jul 03, 2014 3:32 pm

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

chrisw
Posts: 11
Joined: Thu Jul 03, 2014 8:45 am

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

Post by chrisw » Thu Jul 03, 2014 4:24 pm

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

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

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

Post by Klaus » Thu Jul 03, 2014 5:29 pm

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

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

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

Post by jmburnod » Thu Jul 03, 2014 5:59 pm

Hi Chris,
Try this:

Code: Select all

on rawkeyup pKey
   put pKey
end rawkeyup
Best regards
Jean-Marc
https://alternatic.ch

chrisw
Posts: 11
Joined: Thu Jul 03, 2014 8:45 am

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

Post by chrisw » Fri Jul 04, 2014 8:10 am

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

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

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

Post by jmburnod » Sat Jul 05, 2014 6:36 pm

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
https://alternatic.ch

Post Reply