I Have a ListBox on my From with several items in it. When the User clicks an item (OnClick Event) the Users Status is changed and a TCP server is notified. If I use the Arrow Keys On the Keyboard, the Same Event Is called, like an OnChange Event. However There is no OnChange Event.
The Problem with using the arrow keys is that If a User rapidly moves across several items, my Notify Server Method is called several times. (this is not good)
To Get around this I Put a Timer on the OnKeyPress Event. When The arrow keys are pressed If the user stops pushing the arrow key for 2seconds, the Notify Server Method is called, Notifying the server once. (In theory)
Both OnKeyPress and OnClick are still called.
Is anyone familiar enough with TListbox to explain to me why this happens, and if there is a better way of thinking about this problem? The User Requirements are to use a Listbox, and to Not disable the arrow keys.
This is documented behaviour:
From the perspective of the user, why should using the keyboard be discriminated against. If I want to select the item immediately below the current selection then why does it matter whether I use the mouse or the keyboard. Some users don't even have mice.
You need to design your program to be resilient to such actions. Your current approach is not unreasonable. I'd take the same approach even if the user clicked with the mouse. Users often miss and need to click again. So, wait for a short period of time after
OnClick
before responding.Another approach might be to make the user actively invoke the action. So, provide a button, perhaps captioned Apply and only do work when the user presses it.