Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grid Behavior 1

Status
Not open for further replies.

Scott24x7

Programmer
Jul 12, 2001
2,791
10
38
JP
Hi all,
I noticed recently that "modern" applications will generally allow scrolling text when the text is larger than fits the control, simply when the mouse is hovering over that control. And I realized, in one of my own applications that this "intuitive" behavior wasn't there. I have a grid that contains the values for companies. But if I click in another grid I have on a contact, and then "hover" back over the companies grid, the mouse wheel still thinks I'm in the contact grid.
I then thought, ok, I'll just use the MouseEnter() event to do something like "This.GotFocus()", but it turns out GRID control doesn't have a GotFocus method... Which lead me to realize, than when I initially click the grid control, it doesn't select the row I'm hovering over, that acts a a "Click" event AFTER the grid is clicked on again, so I don't get how the "Focus" is getting set on a Grid without a GotFocus() event?

So what I would like achieve is the ability to just hover over the control and allow me to scroll the control without having to click on it first.
Does this make sense? Is there any way to mimic this behavior with VFP 9?


Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
I was wrong about one of my statements above.
When I click the grid, wherever I do click it activates the row. And then I can begin scrolling. I'd like to be able to just hover over the grid, and then scroll... I guess I could put a "CLICK()" event in the mouse enter, but that seems a little kludgey, and might yield "double" click behavior if I then click on it once.

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
We have the [highlight #FFFF00]SET[/highlight]Focus method to set focus to something. Even the grid has that, though it rather compares to a form, container, page or anything containing controls.

Bye, Olaf.
 
Olaf,
Oh that is perfect. I got all fixated on GotFocus and totally forgot about SetFocus. So I just added that to mouse enter over the grid, and it's perfect... time to apply that to the base class!
Many thanks.


Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
You won't get any of this to work with a grid. Think of the grid as windows of a modern skyscraper and you're standing on the outside. Those windows don't open. They don't do anything except let you look inside. By default what you get on the inside is a textbox. You can replace that text box with a different textbox or a spinner or a combobox or a checkbox. Whatever control os the inside of that window is what does all the work. That's where you need to play with methods and properties to do things.

Craig Berntson
.Net MVP, Author, Tech Presenter
 
Craig,
Actually, it works perfectly... I don't see any issue. That's what MouseEnter event is all about...

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
What craig points out is, you could have set focus to the real controls inside the grid.

Well, I can't scroll browser content with the mousewheel before activating the content window with a click.

But you described the UI behaviour you want to implement this way and that may reflect other things, maybe WPF/XAML, it also sounds a bit like tiptext popping up with the full text display. But no, it's not the normal case a mouse enter already focuses a control.


Just a little anecdote about stubborn ignorance:
I once had a discussion with a user wanting "B" as a hotkey for focussing a textbox receiving a barcode scan, as that always was that way in an old DOS implementation. They didn't think about the progress the application and it's forms made to have much more features now, eg also being able to write a note. So there was the requirement to type text, any text, also words starting with b or - which also sometimes occurs - containing b in any other position inside them.

Some users have that mindset to insist on getting impossible wishes fulfilled and can't even recognise they insist on a bad and not working idea.

I don't consider autofocusing a grid or something in it with a mouse enter in that league, Scott, no comparison, but I'd like to see what you really want to imitate, because there could be a much simpler solution.

Bye, Olaf.
 
Olaf,
I appreciate your awareness, and point on this. And you know my interface design experience is a little rusty, but this time I was modeling it off of behavior I have in other applications.
Here's a "modern day" example.
I am a presidential election sort of super freak, and I like to keep very detailed results, down to county level. I have an Excel spreadsheet that I have each state and the counties identified, but to populate the data I have to have a web site that has the data and the Excel file up at the same time. One of the annoying things about the way the media reports the results (because most people don't care down to the county level) is they show a thematic map, but you have to hover the mouse over the map county to see the details. So... in order to make the entry easy, I have Excel file open on one monitor and "Active" window. I move my mouse onto the web page in the browser, and as you mention tool tip text, this is pretty much what they are doing, is hovering the tool tip text. But when my mouse is over the page, my scroll wheel responds to the object it's over (page/control) even if I haven't clicked on the browser. (And in fact I don't want to click on the browser because if I do, then I have to click back and forth to the Excel file, and the moment I move my mouse away, the text vanishes.) So I have Excel as active window, and I have browser page open to results.
This is just meant to demonstrate the UI behavior I'm seeking. And I have a form in VFP that has 3 grids, I want to be able to scroll those grids without having CLICK on them, because once I select a record, that will reposition records in the other 3 grids (relationship issues). And Even if they didn't the only way to look at other data in them would be to click on them, and that changes the relationship. This behavior (as I describe it) is actually common place in almost every app I use. Maybe you just haven't noticed it. Or maybe it's more obvious in multi-monitor setups across applications, and if you don't do that on a regular basis, it may not be so obvious.
Now I get the "But does this have some other unwanted side effect" concern, as I've been bitten by that in the past too, but after using it for a day, so far, I see no issue with this, and have added at the sub-class of my grid level MouseEnterEvent This.SetFocus() so far, it's created no conflict, but I'm keeping an eye on it. It's actually very nice UI behavior...

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Well, what browser are you using? What map are you referring to?
I won't follow up the UI guidelines of MS, they are guidelines anyway, but I'd really like to see a concrete example myself, not just a description. Do you have a link?

I already said I have to click the browser to let the whole window content scroll, you refer to a tooltip like popup in a browser, which appears at mouseover. Totally believable, that has nothing to do with Windows UI. You argue with the "others do it, too" argument. It's not always a good one.

>I don't want to click on the browser because if I do, then I have to click back and forth to the Excel file
But you do this with the VFP grid, so you don't fully emulate the same behaviour. I'd say you argue that has to be done to make the scroll wheel work, but if you'd be after the same advantage you have in your case, you'd need to think about how to generally catch the mousewheel events and make them scroll the control under the mouse.

You can get the control under the mouse by Sys'(1270,x,y) and you can get mouse events via Bindevent to Windows Messages not only for a single control as with the mouseenter event, if you want to be serious about this.

Bye, Olaf.
 
Hi Olaf,
Sure, here is a link: I get the same behavior in Chrome, FireFox and IE. I never "click" on the browser at all after I click on the spreadsheet to make it active. After that, as long s I have the page open, I just need move my mouse over the object (county on a map in this case), and the data is there. In addition, if I move the mouse scroll wheel while over this page (which is longer than the monitor can display), then the browser window scrolls with me, once again WITHOUT the need to have clicked anywhere on the browser or page.
You can set focus to an excel cell, move the mouse over, and you retain active window as Excel, can add figures to columsn move them by cursor keys, and also move the mouse over the browser page, and get data related to mouse hover point, and/or scroll the page.
-S

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Oh, and by the way, that action is reversible. If you set the focus to the browser, and then put your mouse over Excel, and move the scroll wheel, without activating that window, Excel will also respond, and scroll the sheet accordingly.

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
One more note...
It also works if the window is behind another. Simply entering into the window will allow you to scroll wheel without clicking on it.
Now my VFP app behaves the same way over scroll-able grid control. I assume if I add it to other scrolling region controls (Like Edit and List Box) I will also have the same behavior. Because no click or other events take place, it seems to be "harmless"... so far. And matching modern UI behavior...
-S

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
The immediate popup windows over the map could be done by tooltip in VFP too, or via mouseenter, obviously, ie if you set _TOOLTIPTIMEOUT=0 you also have immediate tips in VFP.

Scott said:
In addition, if I move the mouse scroll wheel while over this page (which is longer than the monitor can display), then the browser window scrolls with me, once again WITHOUT the need to have clicked anywhere on the browser or page.

That's not the way it works for me. I need to click the other browser window to scroll there. So it turns out to me, you have a mouse driver setting enabling this to you.

My mouse driver has no such setting, only allowing to choose the number of lines a wheel step causes in the active window or letting each mouse wheel step cause a whole page scroll.

I'm not sure I ever saw drivers allowing to redirect the mousewheel event to whatever is under the mouse currently, but I'd say that's a possible explanation for your experience. It's not a default at all. It might be a setting you have to do per application or a setting not compatible with VFP, anyway no Windows default. Anything in browsers is not Window UI, it's browser and HTML specific.

Bye, Olaf.
 
Olaf,
Let me clarify as well. I'm running no special mouse driver, and I've done this with 3 mice... A wireless Logicool, a wired Drakonia, and a wired G-15 Armageddon mouse. I will also clarify, I'm running Windows 10 Insider Preview 14267, though that said, I've been able to use this UI behavior since Win 8.0 at least...
-S

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
And as another point, I think I mentioned earlier, it's not limited to VFP and browser. If I have, say, browser on top, and a PDF using Acrobat Reader under it, and VFP window open, if I make VFP the active window, and then over over the PDF which is BEHIND the browser window, and I scroll on that, then the PDF pages change/move as well. And if I put VFP behind say, a WORD window, with just part of it visible, and I can move the mouse into the grid area, and scroll, it moves the grid. This is not some "magic" behavior I have created, this is native to Windows.


Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Well, at least it's not the behaviour under Windows 7 Ultimate.

Anyway, if Windows 8+ has this mouse wheel behaviour, the question is why VFP doesn't inherit this. When VFP9 was new we had XP and Vista at most at the advent of SP2. Maybe that's the reasoning.

Bye, Olaf.
 
Interesting. It doesn't "feel" new to me, but it could be behavior since Win7. I've not used Win7 since the time Win8 beta was available... (I tend to be early adopter on OS). But it's been the behavior I 'recall' for quite a long time.

And in any case, I really do like this UI feature. And there still seems "no harm" at least with how I manage the VFP UI otherwise for Grid and "scroll-able field" controls.

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
No harm, that's not why I'm after it. Not only. I just want to go to the bottom of the why VFP does not do it natively.

Side note: It's not Windows 7 behaviour, for sure. I now also have tried many more applications and also some mices to no avail. You are too sure in seeing this in everything else but VFP.

There might be an easier solution. As analogy: OS() does not return any newer value than "Windows 6.02" in VFP9.exe, but only, because you need a manifest embedded in an EXEcutable telling Windows you want to be aware of newer OS versions, EXEs not having that manifest get the old value to behave legacy. This is a compatibilty feature and if you ask me another questionable decision from Microsoft.

I'm not saying manifests are the solution for anything, but there might be any setting making VFP scroll in the same manner from Windows 8 onwards. VFP is in principle capable to react to mouswheel, it does so, when focussed. Mousewheel events are simply translated to arrow keys and pageup/down keys and VFP is capable to react to these keys and WM_KEYDOWN/KEYUP events, they just need to be sent to its HWND.

What you do by automatically setting the focus is giving you a solution, but it's not equal to the native behaviour, the native behaviour you tell is the scrolling happens in non focused/non active windows. I consider it more intuitive the mouse scrolls what's beneath it, but I'd not like focus to be taken away. You might move the mouse or a truck driving by might "move" the mouse by vibrations and focus is taken elsewhere while you type. There are many reasons - if only consistency - to emulate the behaviour 1:1, when you decide to emulate it in legacy apps, too. There is SYS(1270,mousex,mousey) telling you the object under the mouse, that for example would be another root element to make that behaviour more to the point, because you then can do object.scroll() without focusing it. Your only walk half the mile and are satisfied with the main feature applied.

If you are after consisency you'd push it more.

Bye, Olaf.
 
Olaf,
But with 1270, don't I have to constantly keep track of where the mouse is, and then constantly check that against what object is also at that position? That seems even more "clunky" then the SetFocus() on mouse entry. I get your point about mouse movement and entry... but I think that is something that is a more rare case, and there are plenty of other things that have that same result non-VFP related as well. I like your thinking about pushing beyond to see what happens, but sometimes, the simple solution is a simple solution. I'll keep any eye on it, but so long as this remains consistent behavior with modern OS UI, I'm satisfied with the outcome. Note my tag line... "Everything should be made as simple as possible, and no simpler..." I've had that there for two decades now as a reminder of just this type of thing.


Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Yes, I noticed this signature baseline. I configured my browsers to not show gif animations. Anyway, "but no simpler" more often means more complicated than you wish you could do something, to fulfill the thought of the "no simpler" - to not make it wrong by oversimplyfications. This motto is indeed not the motto of someone favouring simple solutions per se for the simplicity of them. Surely not what you'd interpret into this Einstein quote, but it's actually out of the context of people asking for a simple explanation of relativity (or put in any complexer theory) and stating things, which are complicated are complicated and can't be simplified without differing from the whole truth.

I think along the line of Bindevent to WM_MOUSEMOVE, using SYS(1270) at that times and maintaining a oCurrentUnderMouseControl. Anyway, more than that I ideally thought of finding a simple setting, regkey or such, but haven't found how this Windows Mouse behaviour is controlled and could be set for VFP apps, too without ANY code whatsoever.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top