Modifier Keys not properly changing in a Windows VM

  • Thread starter Thread starter Parallels User
  • Start date Start date
P

Parallels User

I'm seeing something odd with Parallels 11 running Windows 10 on El Capitan. I think the issue however is with Parallels. It seems you can't check the modifier keys if you're in a Mouse event with a mouse key pressed.

I'm observing if the mouse is currently down, Parallels only sends/stores the modifier key changes when a mouse button or different, non-modifier keyboard key changes state (or a different modifier key is released, but not when pressed).

So... anyone know how to get around this? We definitely want to support Parallels. (I've also filed a bug with them about this because it definitely seems wrong.)

Here's some sample C#/WPF code which you can run in the free Community version of Visual Studio 2015 which shows the issue. Simply create a new project and paste this into the code-behind of the main window.

Code:
bool isDragging;

protected override void OnMouseDown(MouseButtonEventArgs e)
{
    if(e.ClickCount == 1 && e.ChangedButton == MouseButton.Left)
    {
        e.Handled = true;
        isDragging = true;
        CaptureMouse();
    }
    base.OnMouseDown(e);
}

protected override void OnMouseMove(MouseEventArgs e)
{
    if(isDragging)
    {
        e.Handled = true;
        // This next line does not update as expected
        Title = "Pressed: " + (Keyboard.Modifiers == ModifierKeys.Shift);
    }
    base.OnMouseMove(e);
}

protected override void OnMouseUp(MouseButtonEventArgs e)
{
    if(isDragging && e.ChangedButton == MouseButton.Left)
    {
        e.Handled = true;
        isDragging = false;
        ReleaseMouseCapture();
    }
    base.OnMouseUp(e);
}

I've added a question on StackOverflow about this. You can find that here...

http://stackoverflow.com/questions/...te-during-a-mouse-move-operation-in-parallels
 
Last edited by a moderator:
Back
Top