[英]Why don't modifier keys' state change as expected during mouse move operations?
Wondering if anyone else is having this issue. 想知道是否还有其他人遇到这个问题。 While using a Windows 10 VM in Parallels 11 on El Capitan, it seems you can't check the modifier keys if you're in a Mouse event with a mouse key pressed.
在El Capitan上的Parallels 11中使用Windows 10 VM时,如果您在按下鼠标键的Mouse事件中似乎无法检查修改键。
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). 我正在观察鼠标当前是否处于按下状态,Parallels仅在鼠标按钮或其他非修改器键盘键更改状态(或释放其他修改器键,但未按下时)时发送/存储修改器键更改。
So... anyone know how to get around this? 所以...有人知道如何解决这个问题吗? We definitely want to support Parallels.
我们绝对希望支持Parallels。 (I've also filed a bug with them about this because it definitely seems wrong.)
(我也已经向他们提交了一个错误,因为这肯定是错误的。)
Here's the code. 这是代码。 Simply create a new project and paste this into the code-behind of the main window.
只需创建一个新项目并将其粘贴到主窗口的代码中即可。
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;
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);
}
Aaaaah! Aaaaah! Problem solved!
问题解决了! It's not a bug per se, but it is caused by Parallels and is something you have to explicitly enable.
它本身不是错误,而是由Parallels引起的,必须明确启用它。
Specifically you have to change your keyboard's setting to 'Optimize for games'. 具体来说,您必须将键盘设置更改为“针对游戏进行优化”。 This tells Parallels to be more verbose with key notification messages.
这告诉Parallels在按键通知消息上更为冗长。
Why they decided to call it 'Optimize for games' instead of something more informative, or at least better explained what that feature does is beyond me. 为什么他们决定将其称为“针对游戏进行优化”,而不是提供更多信息,或者至少更好地解释了该功能的作用超出了我。 Days of testing and trying work-arounds followed by a bug report filed with Parallels only to find out it's controllable with a setting.
经过数天的测试和尝试,然后通过Parallels提交了错误报告,才发现可以通过设置来控制它。 And that's from me, a software architect.
那是我,软件架构师。 I can't even imagine what the non-techie would go through here.
我什至无法想象非技术人员会经历什么。 Really bad call on the part of Parallels.
Parallels确实很糟糕。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.