Link to home
Start Free TrialLog in
Avatar of Mutley2003
Mutley2003

asked on

Elegant IdleMonitor component

Context: a data entry app.. the emphasis is on speed of keyboarding. So the operator/user should not have to take his/her hands from the keyboard at all. Sometimes the operator gets "stuck" .. unsure of what to do next, or "where" he/she is. She needs a little prompt that comes up automatically (not a special keystroke) after eg 0.5 seconds of inactivity.

Assume

1. the prompt is a small form (with custom contents) that does not receive focus and disappears automatically

a) on any keystroke (directed to the calling form: no special keystroke like esc is needed to make it go away)
 or
b)  a "significant" mousemove. Significant defined as more than xx pixels in x direction or yy pixels in y direction .. this is just to filter out noise mousemovements
or
c) tt milliseconds have elapsed

2. That prompt form will never be too large to fit on screen and the calling form will know its dimensions and how to position it.

3. Inactivity (which makes the form appear) is defined as

a) absence of any keystrokes for tt2 milliseconds
b) absence of "significant" mousemoves for tt2 milliseconds

4. Data entry is into a StringGrid


I need starter code for a TIdleMonitor which encapsulates all this, monitors the StringGrid,
 publishes an OnIdle(whichCell,ReasonForIdle) event which I can handle in my caller to display the PromptForm. But I also need an efficient PromptForm.Disappear method .. makes me think that the appearance and disappearance of the PromptForm should be coupled with the IdleMonitor to form a class TPromptOnIdle.

As usual, I am in a hurry.




ASKER CERTIFIED SOLUTION
Avatar of RDWilson2
RDWilson2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mutley2003
Mutley2003

ASKER


RDWilson2 .. thanks for the feedback.

As you say, the logic of caring about the absence of a keystroke and the absence of a mousemove is a little twisted. If neither happen, then you have "idle" .. if either happens,
then you don't.

Re the StringGrid solution .. yes, resetting the Timer whenever a keystroke or mousemove happens will work. Pity I have to put code in 2 locations, but I guess I could always derive a component that puts this work behind the scenes.