Results 1 to 15 of 15

Thread: [RESOLVED] How do you control what the mouse is scrolling?

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,475

    Resolved [RESOLVED] How do you control what the mouse is scrolling?

    I have a winforms application. On one of the screens, I have a lookupedit (by DevExpress - it's basically a dropdownlist) and a gridview. The lookupedit lists our employees and the grid lists what jobs they have or had scheduled, present and past. So for example, if I pick emp id 99 it will show me MMock's schedule in the grid, over time.

    There is a weird scrolling issue going on. If I open up the lookupedit and pick 99, that's pretty far down the list. So when the list closes my mouse is sitting in the middle of the screen on the grid. If I use the scroll wheel, my grid scrolls. This makes sense. My mouse is hovered over the grid.

    This is not what is happening to my boss. When she scrolls, it's scrolling her emp's. Most likely if she's just picked an emp and she scrolls, it's to see their schedule not pick a new emp. This is how she wrote up the problem:

    When you select an EMP from the main form, the focus stays on the EMP field. if you scroll it scrolls the emp. Change focus to main grid after selection so you can scroll the grid.

    But is it a focus problem? Is it some kind of mouse hardware thing and that's why it's different for her vs me?

    Just in: I tried a new mouse on my PC, and it doesn't scroll at all! If I click emp 99 and the list closes and my cursor is hanging out on a textbox or a label, the scrollwheel does nothing. I am kind of confused here.

    Thanks.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: How do you control what the mouse is scrolling?

    This behaviour is specified by the mouse driver, and can often be configured in the driver settings via Control Panel.

    However... that is a per-user setting which affects other programs, so isn't something that you should be attempting to alter.

    Simply setting focus to the grid by code (when an item is selected in the lookupedit control) is likely to alter this behaviour in the way it is wanted.

  3. #3

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,475

    Re: How do you control what the mouse is scrolling?

    Quote Originally Posted by si_the_geek View Post
    Simply setting focus to the grid by code (when an item is selected in the lookupedit control) is likely to alter this behaviour in the way it is wanted.
    Yes, I tried:
    Code:
            private void lkupViewEmpId_EditValueChanged(object sender, EventArgs e)
            {
                if (lkupViewEmpId.EditValue != null)
                    LoadViewByEmpIdSelected((string)lkupViewEmpId.EditValue);
    
                // 10/04/17 - Put the focus on the main grid for scrolling.
                gvSchedule.Focus();
    
            }
    If that is what you recommend I will take a further look why it isn't working. Thanks.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: How do you control what the mouse is scrolling?

    I don't know the control, but I assume that is the right event... in which case I would recommend looking into the mouse settings on the problem computer(s) to see if they differ from yours.

    I'm not sure what step to take next tho, as I think setting focus like that has always worked for me (at least to the point the users expected from their computers).

  5. #5

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,475

    Re: How do you control what the mouse is scrolling?

    Yeah, I decided to post a question to DevExpress. I realize they may say it's not a problem with their controls but perhaps they can help.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  6. #6
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: How do you control what the mouse is scrolling?

    I think this could be tricky because it isn't always which application has the focus.
    For instance, right now if the mouse is over this browser and I use the scroll wheel, the page scrolls up and down.
    If I move the mouse off of the browser, the browser still has the focus but the scroll wheel will not scroll the page.

    As it happens, I have Outlook open, and it is beneath the browser off to one side. If the mouse is over Outlook then when I scroll the wheel I can see the window in the background scrolling an e-mail item up and down.
    If the mouse is over the e-mail folder list, the list of e-mail items scroll up and down. But the whole time, the web browser has the focus and I can type in this response.

    So, if you're going to set the focus to a particular window, you will likely also have to move the mouse pointer so that it is over that window, otherwise it will continue to scroll the window that it is over. This behavior may be subject to driver or configuration options, so may not be consistent across machines, but that is how this computer with Win10 is currently acting.

  7. #7

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,475

    Re: How do you control what the mouse is scrolling?

    Thanks. And I just realized, the two mice I was using on my PC did behave the same way. What was different was where I clicked in the employee dropdown. The dropdown overlaps the main grid. So if I selected an entry by clicking on the far right, I was in the grid and good to go. If I selected the same entry but on the far left, I wasn't in the grid and nothing was scrolling.

    So it's more a mouse hover thing than a focus thing.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  8. #8

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,475

    Re: How do you control what the mouse is scrolling?

    OK, that is on my PC with two difference mice.

    I just went over to someone else's PC. After she picks an employee, regardless where her mouse cursor is on the form, she is scrolling both the grid and the list.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  9. #9
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: How do you control what the mouse is scrolling?

    Right, as I said tricky. The behavior is not standardized, and can depend on Mouse Driver, Operating system, and/or configuration options.
    These type "problems" are what I don't like about Windows, i.e. lack of consistency in the behavior between different machines, even when running the same version of the OS.

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: How do you control what the mouse is scrolling?

    Quote Originally Posted by passel View Post
    These type "problems" are what I don't like about Windows, i.e. lack of consistency in the behavior between different machines, even when running the same version of the OS.
    And someone else will love Linux because it provides even more customisation options.

  11. #11

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,475

    Re: How do you control what the mouse is scrolling?

    For now, I have done this:https://www.devexpress.com/Support/C...upedit-focused. I have to see if it's a solution my users are happy with.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: How do you control what the mouse is scrolling?

    Perhaps this is not an option but I'd suggest that it's not your responsibility to get your application to overcome their system configuration. If they want their mouse to work a particular way then they should configure it to do so.

  13. #13
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,929

    Re: How do you control what the mouse is scrolling?

    Quote Originally Posted by MMock View Post
    For now, I have done this:https://www.devexpress.com/Support/C...upedit-focused. I have to see if it's a solution my users are happy with.
    That looks like a good option, and you should be able to extend it fairly easily if you want (eg: allow wheel scrolling only while it has the focus).

    Quote Originally Posted by jmcilhinney View Post
    Perhaps this is not an option but I'd suggest that it's not your responsibility to get your application to overcome their system configuration. If they want their mouse to work a particular way then they should configure it to do so.
    Normally I would agree, but this particular option is something that often cannot be changed (it depends on the mouse driver etc, my current one doesn't allow you to set it), so it does make sense to do it if reasonably possible.

  14. #14
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: How do you control what the mouse is scrolling?

    Chiming in on the "what SHOULD it be doing?" argument:

    The behavior IS standardized, but complex.

    There are "Forms" and there are "Controls". In Windows API, they are all "Windows" so the documentation gets confusing, let's use the .NET term. The Windows guidelines suggest "only the active window's child controls should respond to mouse events". That means if Program A is the active Window, and Program B is inactive underneath it, the only mouse event program B should respond to is a click, and ONLY to regain focus. However, if the focus is in a TextBox on Program A and you click a Button in Program A, that Button should accept a click even though the button does not have focus. Since "scroll" isn't an action that has the same kind of cursor affinity as a click, it targets "the active control on the active window". Whew.

    They set it up this way partially because when the guidelines were written you didn't have a lot of monitor space, so usually only a tiny portion of Program B would be visible if it was inactive. They didn't want you to click on B, then have some control you couldn't actually see in B assume you meant to click on it.

    The behavior is opposite on Mac OS and presumably Linux. The window beneath the mouse cursor always responds to the events. This is sort of convenient because I can scroll my browser window without necessarily taking focus away from my gvim window where I'm typing.

    Anyway, Windows has a recommendation, that doesn't mean they enforce it. I'm not sure how, but I know Firefox emulates the Mac OS behavior on Windows, so do other applications. I also remember old versions of PowerToys that would make the behavior happen system-wide. I'm not sure precisely what they do. Apple has a little bit more control over how things behave on their systems, so it's consistent even if I don't like how they do it.

    It drives me nuts in Mac OS and in Firefox. I can't tell you how many posts and emails I've lost because I just wanted to switch programs but my mouse click caused a refresh, or hit an ad banner, etc. I very strongly believe clicks should only "stick" in the active window. But scrolling's kind of innocent. I say you should do "whatever feels obvious".
    Last edited by Sitten Spynne; Oct 8th, 2017 at 03:32 PM.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  15. #15

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,475

    Re: How do you control what the mouse is scrolling?

    Quote Originally Posted by jmcilhinney View Post
    Perhaps this is not an option but I'd suggest that it's not your responsibility to get your application to overcome their system configuration. If they want their mouse to work a particular way then they should configure it to do so.
    I guess it's an option but then my boss could always opt to not give me a paycheck! LOL. Anyway, it wasn't too difficult to solve. I implemented the solution in post #11. I have no idea how it looks on my boss's configuration, but she's happy.

    Thanks for the discussion.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width