按下"Ctrl"键了吗? [英] Is 'Ctrl' key pressed?

查看:82
本文介绍了按下"Ctrl"键了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道用户在单击按钮时是否按住 ctrl 键.因为它是一个按钮而不是一个图形,所以我不能在图形等上使用"selectionType".是否有一种简单的方法?

I need to know whether the user is holding down the ctrl key while clicking a button. since it's a button and not a figure I cannot use 'selectionType' on the figure etc. Is there a simple way to do this?

谢谢!

推荐答案

这是怎么回事:

modifiers = get(gcf,'currentModifier');        %(Use an actual figure number if known)
ctrlIsPressed = ismember('control',modifiers);

Figure类具有许多有用的Current*属性,这些属性在处理回调时非常有用.这是检索当前鼠标位置,所选图形对象和(如此处)按下的键的方法.其中包括:CurrentAxes,CurrentCharacter,CurrentKey,CurrentModifier,CurrentObject和CurrentPosition.

The figure class has a number of useful Current* properties which are useful when handling callbacks. This is how to retrieve current mouse position, selected graphics object, and (as here) pressed keys. These include: CurrentAxes, CurrentCharacter, CurrentKey, CurrentModifier, CurrentObject, and CurrentPosition.

这篇关于按下"Ctrl"键了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆