Trapping multiple keystrokes: deliberately misunderstanding this thread

2017-12-02 Thread Richmond Mathewson via use-livecode
So, today I had a meeting with a young man who is attempting to buck the 
trend and do
his high-school programming project using LiveCode against the 
disapproval of his
teacher (who admits her objection to LC is because she knows nothing 
about it).


Anyway, this chap wants to do some stuff messing around with music and 
create effects

by depressing one or more keys on the keyboard at the same time . . .

Not being particularly musical myself (if fiddle lessons from 7 to 14 
getting almost nowhere
are discounted) . . . I thought I'd just knock together a stack doing 
other things with multiple key presses . . .


And, with Arrow keys coupled with other keyDowns there is absolutely no 
problem at all.


Richmond.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Trapping multiple keystrokes

2017-12-01 Thread J. Landman Gay via use-livecode

It's a function, so try

get flushEvents("autoKey")
--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com



On December 1, 2017 4:05:20 PM Kaveh Bazargan via use-livecode 
 wrote:



Hi Paul

It looks like just what I need and thanks for that, but it does not do the
job in my stack and in the single field stack with one line added:


on arrowKey theKey
   put 1 into increment
   put me into current_value
   if theKey is "up" then
  put current_value + increment into the target
  repeat with i = 1 to 100
 put 1+i into temp
  end repeat
   end if -- up
   if theKey is "down" then
  put current_value - increment into the target
   end if -- down
   flushEvents("autoKey")
   pass arrowKey
end arrowKey

(note flushEvents near end)

The stack moves from the front so it no longer sees the arrows. This is a
separate problem I have had. (sorry to bring up this second issue.) Cannot
work out how to bring forward the main stack

On 1 December 2017 at 21:45, Paul Dupuis via use-livecode <
use-livecode@lists.runrev.com> wrote:


On 12/1/2017 1:00 PM, Paul Dupuis via use-livecode wrote:
> On 12/1/2017 12:52 PM, Kaveh Bazargan via use-livecode wrote:
>> I have a field with a number in it. when focused, I want the value to
go up
>> and down with the up/down arrow keys. The trouble is that if I keep the
key
>> down, it traps multiple keydown messages that continue after the key is
>> released.
>>
>> How can I ensure that message are terminated as soon as arrow key is
>> released?
>>
> look at the dictionary entries for 'the pendingMessages' and the
> 'cancel' command
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
what you actually want is flushEvents(eventType) -- see dictionary


just execute flushEvents("autoKey") when you handler is done to clear
extraneous arrowkey messages


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode





--
Kaveh Bazargan
Director
River Valley Technologies  • Twitter
 • LinkedIn

Phone +44 7771 824 111
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your 
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-livecode




___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Trapping multiple keystrokes

2017-12-01 Thread Kaveh Bazargan via use-livecode
Hi Paul

It looks like just what I need and thanks for that, but it does not do the
job in my stack and in the single field stack with one line added:


on arrowKey theKey
   put 1 into increment
   put me into current_value
   if theKey is "up" then
  put current_value + increment into the target
  repeat with i = 1 to 100
 put 1+i into temp
  end repeat
   end if -- up
   if theKey is "down" then
  put current_value - increment into the target
   end if -- down
   flushEvents("autoKey")
   pass arrowKey
end arrowKey

(note flushEvents near end)

The stack moves from the front so it no longer sees the arrows. This is a
separate problem I have had. (sorry to bring up this second issue.) Cannot
work out how to bring forward the main stack

On 1 December 2017 at 21:45, Paul Dupuis via use-livecode <
use-livecode@lists.runrev.com> wrote:

> On 12/1/2017 1:00 PM, Paul Dupuis via use-livecode wrote:
> > On 12/1/2017 12:52 PM, Kaveh Bazargan via use-livecode wrote:
> >> I have a field with a number in it. when focused, I want the value to
> go up
> >> and down with the up/down arrow keys. The trouble is that if I keep the
> key
> >> down, it traps multiple keydown messages that continue after the key is
> >> released.
> >>
> >> How can I ensure that message are terminated as soon as arrow key is
> >> released?
> >>
> > look at the dictionary entries for 'the pendingMessages' and the
> > 'cancel' command
> >
> >
> > ___
> > use-livecode mailing list
> > use-livecode@lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> >
> what you actually want is flushEvents(eventType) -- see dictionary
>
>
> just execute flushEvents("autoKey") when you handler is done to clear
> extraneous arrowkey messages
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



-- 
Kaveh Bazargan
Director
River Valley Technologies  • Twitter
 • LinkedIn

Phone +44 7771 824 111
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Trapping multiple keystrokes

2017-12-01 Thread Paul Dupuis via use-livecode
On 12/1/2017 1:00 PM, Paul Dupuis via use-livecode wrote:
> On 12/1/2017 12:52 PM, Kaveh Bazargan via use-livecode wrote:
>> I have a field with a number in it. when focused, I want the value to go up
>> and down with the up/down arrow keys. The trouble is that if I keep the key
>> down, it traps multiple keydown messages that continue after the key is
>> released.
>>
>> How can I ensure that message are terminated as soon as arrow key is
>> released?
>>
> look at the dictionary entries for 'the pendingMessages' and the
> 'cancel' command
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
what you actually want is flushEvents(eventType) -- see dictionary


just execute flushEvents("autoKey") when you handler is done to clear
extraneous arrowkey messages


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Trapping multiple keystrokes

2017-12-01 Thread Kaveh Bazargan via use-livecode
On 1 December 2017 at 21:29, J. Landman Gay via use-livecode <
use-livecode@lists.runrev.com> wrote:

> On 12/1/17 3:16 PM, Kaveh Bazargan via use-livecode wrote:
>
>> It is the final action I have a problem with, as dozens of arrow key
>> actions are held in the buffer. The number keeps increasing or decreasing
>> and background actions are triggered.
>>
>> Here is a minimal version of the handler I have:
>>
>> on arrowKey theKey
>> if theKey is "up" then
>>put current_value + increment into the target
>> end if -- up
>> if theKey is "down" then
>>put current_value - increment into the target
>> end if -- down
>> pass arrowKey
>> end arrowKey
>>
>
> Works okay here using only the simplified handler you posted (after I
> added values to the variables increment and current_value.) I'm testing in
> LC 9 dp 10. My test handler, located in a field script:
>
> on arrowKey theKey
>   put 1 into increment
>   put me into current_value
>   if theKey is "up" then
> put current_value + increment into the target
>   end if -- up
>   if theKey is "down" then
> put current_value - increment into the target
>   end if -- down
>   pass arrowKey
> end arrowKey
>
> Does this simplified handler work for you? If so, then something farther
> along the message path is duplicating the messages. Unless you need it, try
> removing the "pass" statement.


Thank you so much Jacqueline

This indeed works. But if something is done in the background then the
problem starts. (I am using the same version of LiveCode.)

I tried this:


on arrowKey theKey
   put 1 into increment
   put me into current_value
   if theKey is "up" then
  put current_value + increment into the target
  repeat with i = 1 to 100
 put 1+i into temp
  end repeat
   end if -- up
   if theKey is "down" then
  put current_value - increment into the target
   end if -- down
   pass arrowKey
end arrowKey

The down arrow works but up arrow has the problem I have mentioned.


>
>
> --
> Jacqueline Landman Gay | jac...@hyperactivesw.com
> HyperActive Software   | http://www.hyperactivesw.com
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



-- 
Kaveh Bazargan
Director
River Valley Technologies  • Twitter
 • LinkedIn

Phone +44 7771 824 111
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Trapping multiple keystrokes

2017-12-01 Thread J. Landman Gay via use-livecode

On 12/1/17 3:16 PM, Kaveh Bazargan via use-livecode wrote:

It is the final action I have a problem with, as dozens of arrow key
actions are held in the buffer. The number keeps increasing or decreasing
and background actions are triggered.

Here is a minimal version of the handler I have:

on arrowKey theKey
if theKey is "up" then
   put current_value + increment into the target
end if -- up
if theKey is "down" then
   put current_value - increment into the target
end if -- down
pass arrowKey
end arrowKey


Works okay here using only the simplified handler you posted (after I 
added values to the variables increment and current_value.) I'm testing 
in LC 9 dp 10. My test handler, located in a field script:


on arrowKey theKey
  put 1 into increment
  put me into current_value
  if theKey is "up" then
put current_value + increment into the target
  end if -- up
  if theKey is "down" then
put current_value - increment into the target
  end if -- down
  pass arrowKey
end arrowKey

Does this simplified handler work for you? If so, then something farther 
along the message path is duplicating the messages. Unless you need it, 
try removing the "pass" statement.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Trapping multiple keystrokes

2017-12-01 Thread dunbarx via use-livecode
If you have this in the script of a field:

on arrowKey tKey
   add 1 to me
end arrowKey

The continuous addition stops instantly after release. As Jacque mentioned,
how are you doing it?

Craig Newman



--
Sent from: 
http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Trapping multiple keystrokes

2017-12-01 Thread J. Landman Gay via use-livecode
My understanding of the question is that keydown messages are being 
queued and continue to run to exhaustion even after the key is no longer 
pressed. I couldn't duplicate that behavior.


The rawkeydown handler below will manage keypresses but won't solve a 
backed-up message queue. That's why I asked what the handler looked 
like, there may be something there that is causing the behavior.


Or we've all misunderstood the question. :)

On 12/1/17 3:06 PM, Mike Bonner via use-livecode wrote:

If you're using rawkeydown you can check to see if the key is actually
still down before doing any processing..

on rawkeydown  pKey
 -- since you're checking specifically for arrow keys, you can use pkey
as the first part of the filter..

if pkey is among the items of "65361,65362,65363,65364" then
-- then determine which arrow key(s) are down and respond accordingly.
if 65361 is among the items of the keysdown then -- left arrow key is
currently down
   --do stuff for left arrow key here
end if

if 65362 is among the items of the keysdown then -- up arrow key is
currently down
   --do stuff for up arrow key here
end if
if 65363 is among the items of the keysdown then -- right arrow key is
currently down
 --  do stuff for right arrow key here
end if
if 65364 is among the items of the keysdown then -- downarrow key is
currently down
 --  do stuff for down arrow key here
end if

else
  pass rawkeydown --if a key other than an arrow was pressed, pass it on
end if

end rawkeydown

On Fri, Dec 1, 2017 at 1:27 PM, Richmond Mathewson via use-livecode <
use-livecode@lists.runrev.com> wrote:


I may be a bit stupid, but as far as I understand you are trying to do
this:

1. You keep an arrow key pressed down,

2. You do other things with other keys while the arrow key is pressed down.

I cannot begin to try to answer your question until you either
confirm what I have written or say that I am wrong and then
explain, clearly, what you want to do.

Richmond.

On 1/12/17 10:03 pm, J. Landman Gay via use-livecode wrote:


On 12/1/17 11:52 AM, Kaveh Bazargan via use-livecode wrote:


I have a field with a number in it. when focused, I want the value to go
up
and down with the up/down arrow keys. The trouble is that if I keep the
key
down, it traps multiple keydown messages that continue after the key is
released.

How can I ensure that message are terminated as soon as arrow key is
released?



What handler are you using? I just did a test with rawKeyDown and
arrowKey and they all stop when I release the key. (Though arrowkey seems
to be ignoring left and right keys in LC 9 for some reason.)



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode




--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Trapping multiple keystrokes

2017-12-01 Thread Kaveh Bazargan via use-livecode
Thanks for the replies guys.

Richmond, sorry I was not clear. It is simpler:

   - I click in a field that has a value
   - I press arrow key (up or down)
   - I want the value to change up or down in that field
  - After the value is changed, other actions are triggered, e.g.
  setting the value of a scrollbar to the same value
   - The process continues while I have the arrowkey pressed
   - As soon as I release the system is idle (except for the last arrow
   action that continues)

It is the final action I have a problem with, as dozens of arrow key
actions are held in the buffer. The number keeps increasing or decreasing
and background actions are triggered.

Here is a minimal version of the handler I have:

on arrowKey theKey
   if theKey is "up" then
  put current_value + increment into the target
   end if -- up
   if theKey is "down" then
  put current_value - increment into the target
   end if -- down
   pass arrowKey
end arrowKey



On 1 December 2017 at 20:27, Richmond Mathewson via use-livecode <
use-livecode@lists.runrev.com> wrote:

> I may be a bit stupid, but as far as I understand you are trying to do
> this:
>
> 1. You keep an arrow key pressed down,
>
> 2. You do other things with other keys while the arrow key is pressed down.
>
> I cannot begin to try to answer your question until you either
> confirm what I have written or say that I am wrong and then
> explain, clearly, what you want to do.
>
> Richmond.
>
> On 1/12/17 10:03 pm, J. Landman Gay via use-livecode wrote:
>
>> On 12/1/17 11:52 AM, Kaveh Bazargan via use-livecode wrote:
>>
>>> I have a field with a number in it. when focused, I want the value to go
>>> up
>>> and down with the up/down arrow keys. The trouble is that if I keep the
>>> key
>>> down, it traps multiple keydown messages that continue after the key is
>>> released.
>>>
>>> How can I ensure that message are terminated as soon as arrow key is
>>> released?
>>>
>>>
>> What handler are you using? I just did a test with rawKeyDown and
>> arrowKey and they all stop when I release the key. (Though arrowkey seems
>> to be ignoring left and right keys in LC 9 for some reason.)
>>
>>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



-- 
Kaveh Bazargan
Director
River Valley Technologies  • Twitter
 • LinkedIn

Phone +44 7771 824 111
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Trapping multiple keystrokes

2017-12-01 Thread Mike Bonner via use-livecode
If you're using rawkeydown you can check to see if the key is actually
still down before doing any processing..

on rawkeydown  pKey
-- since you're checking specifically for arrow keys, you can use pkey
as the first part of the filter..

if pkey is among the items of "65361,65362,65363,65364" then
   -- then determine which arrow key(s) are down and respond accordingly.
   if 65361 is among the items of the keysdown then -- left arrow key is
currently down
  --do stuff for left arrow key here
   end if

   if 65362 is among the items of the keysdown then -- up arrow key is
currently down
  --do stuff for up arrow key here
   end if
   if 65363 is among the items of the keysdown then -- right arrow key is
currently down
--  do stuff for right arrow key here
   end if
   if 65364 is among the items of the keysdown then -- downarrow key is
currently down
--  do stuff for down arrow key here
   end if

else
 pass rawkeydown --if a key other than an arrow was pressed, pass it on
end if

end rawkeydown

On Fri, Dec 1, 2017 at 1:27 PM, Richmond Mathewson via use-livecode <
use-livecode@lists.runrev.com> wrote:

> I may be a bit stupid, but as far as I understand you are trying to do
> this:
>
> 1. You keep an arrow key pressed down,
>
> 2. You do other things with other keys while the arrow key is pressed down.
>
> I cannot begin to try to answer your question until you either
> confirm what I have written or say that I am wrong and then
> explain, clearly, what you want to do.
>
> Richmond.
>
> On 1/12/17 10:03 pm, J. Landman Gay via use-livecode wrote:
>
>> On 12/1/17 11:52 AM, Kaveh Bazargan via use-livecode wrote:
>>
>>> I have a field with a number in it. when focused, I want the value to go
>>> up
>>> and down with the up/down arrow keys. The trouble is that if I keep the
>>> key
>>> down, it traps multiple keydown messages that continue after the key is
>>> released.
>>>
>>> How can I ensure that message are terminated as soon as arrow key is
>>> released?
>>>
>>>
>> What handler are you using? I just did a test with rawKeyDown and
>> arrowKey and they all stop when I release the key. (Though arrowkey seems
>> to be ignoring left and right keys in LC 9 for some reason.)
>>
>>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Trapping multiple keystrokes

2017-12-01 Thread Richmond Mathewson via use-livecode

I may be a bit stupid, but as far as I understand you are trying to do this:

1. You keep an arrow key pressed down,

2. You do other things with other keys while the arrow key is pressed down.

I cannot begin to try to answer your question until you either
confirm what I have written or say that I am wrong and then
explain, clearly, what you want to do.

Richmond.

On 1/12/17 10:03 pm, J. Landman Gay via use-livecode wrote:

On 12/1/17 11:52 AM, Kaveh Bazargan via use-livecode wrote:
I have a field with a number in it. when focused, I want the value to 
go up
and down with the up/down arrow keys. The trouble is that if I keep 
the key

down, it traps multiple keydown messages that continue after the key is
released.

How can I ensure that message are terminated as soon as arrow key is
released?



What handler are you using? I just did a test with rawKeyDown and 
arrowKey and they all stop when I release the key. (Though arrowkey 
seems to be ignoring left and right keys in LC 9 for some reason.)




___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Trapping multiple keystrokes

2017-12-01 Thread J. Landman Gay via use-livecode

On 12/1/17 11:52 AM, Kaveh Bazargan via use-livecode wrote:

I have a field with a number in it. when focused, I want the value to go up
and down with the up/down arrow keys. The trouble is that if I keep the key
down, it traps multiple keydown messages that continue after the key is
released.

How can I ensure that message are terminated as soon as arrow key is
released?



What handler are you using? I just did a test with rawKeyDown and 
arrowKey and they all stop when I release the key. (Though arrowkey 
seems to be ignoring left and right keys in LC 9 for some reason.)


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Trapping multiple keystrokes

2017-12-01 Thread Paul Dupuis via use-livecode
On 12/1/2017 12:52 PM, Kaveh Bazargan via use-livecode wrote:
> I have a field with a number in it. when focused, I want the value to go up
> and down with the up/down arrow keys. The trouble is that if I keep the key
> down, it traps multiple keydown messages that continue after the key is
> released.
>
> How can I ensure that message are terminated as soon as arrow key is
> released?
>
look at the dictionary entries for 'the pendingMessages' and the
'cancel' command


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Trapping multiple keystrokes

2017-12-01 Thread Kaveh Bazargan via use-livecode
I have a field with a number in it. when focused, I want the value to go up
and down with the up/down arrow keys. The trouble is that if I keep the key
down, it traps multiple keydown messages that continue after the key is
released.

How can I ensure that message are terminated as soon as arrow key is
released?

-- 
Kaveh Bazargan
Director
River Valley Technologies  • Twitter
 • LinkedIn

Phone +44 7771 824 111
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode