1

Disable multiple pressing on a keystroke untill previous request completes.

asked 2016-09-15 06:02:23 +0800

Vishaltyagi700 gravatar image Vishaltyagi700
13 2

I am listening on certain CtrlKeys which includes ctrl+a ,the processing of the particular business logic takes 2-10 seconds and in that time i want that no more further requests are queued for that key [or any key that i am listening on -OPTIONAL] and only queue request that after the process completes .

win.setCtrlKeys("#f1#f2#f6#f7#f8#f9#f12#left#right#pgup#pgdn#up#down@b@g@i@k@l@n@o@p@r@s@u^x^a^c^z^1^2^#up^#down");
win.addEventListener("onCtrlKey", keylistener);

keylistener here is my event that implements business logic to cater all the keys mapped and pressed.What currently happens is the keys pressed multiple times in the meantime are queued and add to multiple request sent to server which at times lead to chaos .Is it possible in ZKOSS ,or any workarounds?

delete flag offensive retag edit

Comments

I suggest disable or remove your eventhandler for Keys. Echo the bussines logic event. After that reenable the key listener

chillworld ( 2016-09-17 05:31:12 +0800 )edit

@chillworld Yes,thanks this approach worked in my case.Please post this as an Answer.

Vishaltyagi700 ( 2016-09-17 10:36:25 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-09-18 13:29:58 +0800

chillworld gravatar image chillworld flag of Belgium
5322 4 9
https://github.com/chillw...

I suggest removing or disabling your eventhandler for the keys in the first place.
After that, you echo an event that will trigger the effective business logic.

The reason for echoing is that the disabling key's will be propagated to the client before beginning the business logic. When the bussines logic is done, you can enable or add the eventlistener for the keys again.

Greetz chill.

link publish delete flag offensive edit
0

answered 2016-09-16 08:09:31 +0800

Darksu gravatar image Darksu
1991 1 4

Hello Vishaltyagi700,

You could use long operations as shown below:

https://www.zkoss.org/wiki/SmallTalks/2015/January/SimplifyLongOperationHandlings

Best Regards,

Darksu

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2016-09-15 06:02:23 +0800

Seen: 28 times

Last updated: Sep 18 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More