问题描述
我需要知道用户在单击按钮时是否按住键.因为它是一个按钮而不是一个图形,所以我不能在图形等上使用"selectionType".是否有一种简单的方法?
I need to know whether the user is holding down the 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"键了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!