Link to home
Start Free TrialLog in
Avatar of Mutley2003
Mutley2003

asked on

hint or hint alternative - mouse location aware - within a grid component

I want to use hint-like functionality in a grid being used for data-entry : the grid is actually a TopGrid but the same conceptual problem applies to other sorts of grids.

I want my user, if he/she hesitates for more than a specified period, to be given a hint window .. like, what to do now. But this has to be position sensitive (X and Y coordinates which I can map to grid cells easily enough) , so there is different help given dependent upon where the user is. The help mostly depends upon the row number, but does need to be dynamically created.

The hint mechanism in Delphi is quite nice but it is "component specific" .. you can get a hint when you move into or out of this grid but the context (the X and Y) are dependent upon how the mouse moved into the grid. And this is never updated while the mouse remains within the grid.

Some sort of lighweight monitor of mousemoves within the grid would appear to be a promising line of enquiry. But that sorta sounds like hooks, and then I have to monitor periods for which the mouse stayed in a given rectangle  .. sheesh

I gotta get this one out of the way and move on.

Avatar of kretzschmar
kretzschmar
Flag of Germany image

define an application.onShowHint procedure

in this event you have all to evaluate what hint should be shown
and the control of the hinttext, which should displayed

meikl ;-)
SOLUTION
Avatar of gmayo
gmayo
Flag of United Kingdom of Great Britain and Northern Ireland image

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
>Meikl's answer would work the first time you enter the grid and pause, but it won't work where the user changes to >a different portion of the grid and hovers without exiting the grid.

not really, just set the ReshowTimeout-attribut of the THintInfo-parameter-record of this event to a value

just see in delphi-help file about THintInfo

ReshowTimeout       
How long the hint system should wait before asking about the hint status again. By default, this field is zero, indicating that the hint status will not change. Setting it to a non-zero value will cause the hint to act, after the requested milliseconds have elapsed, as if the user moved the mouse outside the hint rectangle and back in. This can be used to either put off hint processing for a period of time, or to allow the hint to be updated periodically.

sample follows later, just no time yet

meikl ;-)
ASKER CERTIFIED SOLUTION
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


ReshowTimeout is a good solution thanks kretzschmar.

gmayo .. I did try your solution- it seems to work and I observed the same apparent mousemoves when there is none(eg just on tab) but I don't understand why exactly you have to recreate the hint window .. ok I rtfm'd and found that ActivateHint requires ReleaseHandle to hide the hint window thus displayed. I had not thought of THintWindow and it seems to me that the dynamic approach of gmayo offers some potential extra flexibility. So I split the points. Gmayo .. seems to me that your timer approach leaks memory though - new instances of ThintWindow are being created every time the timer fires but only being released if there is a mousemove.

OT, I am no longer sure that using hints over cells is such a great idea. It is hard for the user to see where the cursor is , particularly if the cursor is a I bar and the cells are small. I changed the code to display the hint only over the focussed cell .. that results in an OK user experience, but of course tabbing around the grid will not result in the hint coming up
unless the user moves the mouse .

Since this is a data entry app, that requirement (to move the hand of the keyboard) is not acceptable. See new question.


Yes, I was aware my program wasn't perfect but I ran out of time... glad you got it worked out.

Geoff M.