Clicking off of filter dropdown causes weird focus issue

Posted by: jacobturley on 12 February 2018, 12:32 pm EST

  • Posted 12 February 2018, 12:32 pm EST

    Hey! So first of all I know this issue isn’t completely caused by you, but our other software vendor is of little help so I am trying to figure out a work around. Basically when we click the filter drop down the main screen loses focus, which is fine. However, when we click anywhere off of the filter drop down(i.e. on the grid or the title bar) the other software vendor is having issues and sends the focus back to the last active window that isn’t controlled by the other software vendor(i.e. file explorer). When we click the “cancel” button, it works as expected. Is there ANY way that we can replicate that cancel button when the user clicks off of the filter form??? This is a HUGE issue for us :frowning:

  • Posted 12 February 2018, 12:35 pm EST

    Here is a video showing what I am talking about.bandicam 2018-02-12 08-48-28-183.zip

  • Posted 12 February 2018, 1:08 pm EST

    Basically when the form closes after you click off of the filter drop down, it isn’t going down the same path as the cancel, and that is causing major issues.

  • Posted 13 February 2018, 7:23 am EST

    Hi Jacob!

    Thanks for the details.

    "Is there ANY way that we can replicate that cancel button when the user clicks off of the filter form??? "

    • Though there could not be found any workaround as of now, can you please try replicating the issue using C1 and MS controls only?

      Then, it would be easier for the team to investigate this issue further. Currently, we are unable to replicate this.

    Thanks,

    Meenakshi

  • Posted 13 February 2018, 11:21 am EST

    FilterMenu.zip

    I went ahead and attached the zip file. I cannot get it to reproduce the exact behavior, but I CAN get it to reproduce the behavior that is causing it if that makes sense.

    Basically, if you do the filter drop down, and then hit cancel, you will notice the focus goes BACK to the main window. However, if you just click off of the drop down form to make it go away, you will notice that focus does NOT get transferred back to the main window. It seems that is what is causing the issue.

  • Posted 14 February 2018, 9:13 am EST

    Hello Jacob,

    Thank you for attaching the application.

    Is there ANY way that we can replicate that cancel button when the user clicks off of the filter form

    For programmatically performing cancel button click, one way to get around this is to access that cancel button of the filter-editor form and invoke its PerformClick method, when the input focus leaves.

    Following is the code snippet for the same:

    private void _flex_MouseDown(object sender, MouseEventArgs e)
            {
                if (_flex.HitTest().Type == C1.Win.C1FlexGrid.HitTestTypeEnum.FilterIcon)
                {
                    FilterWindowFocusLoss();
                }
            }
            private void FilterWindowFocusLoss()
            {
                foreach (Form f in Application.OpenForms)
                {
                    if (f.Name == "FilterEditorForm" && f.GetType().ToString() == "C1.Win.C1FlexGrid.FilterEditorForm")
                    {
                        frmLocation = f.Location;
                        cancelBtn= (((ToolStrip)(f.Controls[0])).Items[0] as ToolStripItem);
                    }
                }
            }
    

    Now, you can call the PerformClick method whenever required like, MouseLeave event etc.

    cancelBtn.PerformClick();
    

    Hope this helps you.

    Regards,

    Ruchir Agarwal

  • Posted 14 February 2018, 10:41 am EST

    Unfortunately no :(. When the user clicks the mouse(even if it is outside the control’s area of influence) the form will close and produce the bad behavior. I tried tapping into the form closing event and firing it off there but still to no avail :confused: It seems that the focus lost issue happens where I just can’t stop it. I can do something after the fact it seems, but by then it is too late.

  • Posted 14 February 2018, 10:46 am EST

    Also, this happens even if they click on the title bar of the top level control(which is not a c# windows form but it is a windows window if that makes sense) and there is nothing we can do to circumvent that behavior. Honestly if clicking off the filter drop down just went down the same path as the cancel button it would be fixed… Also, the cancel button and the user clicking off of the filter drop down produce the same form closing reason, so there is no way for me to filter off of that.

  • Posted 15 February 2018, 9:36 am EST

    Jacob,

    I could observe the same, hence I am discussing this with development team to see if there is anything we can do to have same behavior [Tracking ID: 309220]

    ~Ruchir Agarwal

  • Posted 16 February 2018, 6:33 pm EST

    Hi, I am Geri, and I am Jacob’s coworker. I have done some additional testing on this issue, so maybe this will help clarify. To review, our application is written in COBOL, and we have a COBOL window that “hosts” a C# UserControl which has FlexGrid on it. It works quite well. However, we discovered an issue when using filtering. We click on the arrow button in the column header, and the Filter window opens. If we close it by clicking either Apply or Cancel, focus returns to FlexGrid. But if we click anywhere off the panel instead of the either of those buttons, focus changes to the most recently active desktop window, which usually displays over the top of our app.

    As I was testing, I displayed a message during the FormClosed event. It looked like it fired 2 times. The first time it brought focus to the most recently active window, and the second time, it brought focus to the second most recently active window. This made me think that maybe focus was moving down a stack or list of active windows. And because the COBOL “window” is not a true active window, it is never registered in this stack or list, and it is skipped when focus is transferred. If this is indeed what is happening, I don’t know if it can be “fixed”. I tried putting a Form on the UserControl to see if that would give a “parent anchor”, but the same behavior occurred, likely because it is still hosted by COBOL.

    However, we see that when the Apply or Cancel buttons are clicked, focus returns to FlexGrid, as we would expect it too. I recognize that it is pretty simple to trigger behavior from a button click, and more difficult to trigger from a mouse movement or loss of focus. But it would seem logical to ALWAYS transfer focus from the Filter window to FlexGrid, regardless of the reason for the Filter window closing. Even if a different desktop window becomes active while the Filter window is open, I would expect the Filter window to close (momentarily returning focus to FlexGrid) before the new active window comes to focus.

    Is it possible to verify any of this? I’m not very experienced with system-level programming. And by the way, this all tests fine in a pure C# environment, probably because of some “default” Windows behavior when it comes to transferring focus.

  • Posted 19 February 2018, 8:51 am EST

    Thank you Geri for researching more into this issue. Your findings have been shared with the concerned person.

    Also, the developer is currently looking over it. We will respond to you once we get an update and/or it is resolved/fixed.

    ~Ruchir

  • Posted 28 February 2018, 11:03 am EST

    Any update on this? This is currently a blocker for us.

  • Posted 28 February 2018, 11:54 pm EST

    Hello,

    Though, this case is currently under investigation and the developers are working over it, I have informed the related person about the criticality of this issue for you and have also increased its priority.

    Hopefully we would get back to you soon on this.

    Regards,

    Ruchir Agarwal

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels