ジャンプ先: 概要. 戻り値. フラグ. Python 例.

概要

hotkeyCheck([altModifier=boolean], [commandModifier=boolean], [ctrlModifier=boolean], [isRepeatable=boolean], [keyString=string], [keyUp=boolean], [optionModifier=boolean])

注: オブジェクトの名前と引数を表す文字列は、カンマで区切る必要があります。これはシノプシスに示されていません。

hotkeyCheck は、取り消し可能、照会不可能、および編集不可能です。

このコマンドは、指定したホットキーが nameCommand オブジェクトにマップされているかどうかをチェックします。マップされている場合は、nameCommand オブジェクトの注釈が返されます。マップされていない場合は、空の文字列が返されます。

戻り値

stringすべてのクライアント名を含みます(各クライアント名の後に、対応する nameCommand オブジェクトの注釈または空の文字列が続きます)。

フラグ

altModifier, commandModifier, ctrlModifier, isRepeatable, keyString, keyUp, optionModifier
ロング ネーム(ショート ネーム) 引数タイプ プロパティ
altModifier(alt) boolean create
Alt キーを押すかどうかを指定します。
commandModifier(cmd) boolean create
コマンド キーを押すかどうかを指定します。
ctrlModifier(ctl) boolean create
Ctrl キーを押すかどうかを指定します。
isRepeatable(ir) boolean create
ホットキーが繰り返し可能である場合は、このフラグを指定します。
keyString(k) string create
チェックするキーです。
keyUp(kup) boolean create
ホットキーをキーアップまたはキーダウンにするか(つまり離すか押すか)を指定します。
optionModifier(opt) boolean create
option キーを押すかどうかを指定します。

フラグはコマンドの作成モードで表示できます フラグはコマンドの編集モードで表示できます
フラグはコマンドの照会モードで表示できます フラグに複数の引数を指定し、タプルまたはリストとして渡すことができます。

Python 例

import maya.cmds as cmds

#    Create a window in which you can type a hotkey character
#    and determine via the 'hotkeyCheck' command the annotation
#    of the command attached.
#
window = cmds.window( title='hotkeyCheck Example' )
cmds.columnLayout( adjustableColumn=True )

#    A few instructions in a scrollField for the user.
#
instructions = "Enter a single character in the field below.  \
Then press the 'Query' button to determine the annotation of the command attached to that hotkey."

cmds.scrollField( text=instructions, editable=False, height=120, wordWrap=True )
textFieldGrp = cmds.textFieldGrp( label="Enter a single hotkey character", text='a', columnWidth2=(200, 50) )

#    Create a couple controls for specifying modifier keys and the
#    key press/release information.
#
checkBoxGrp = cmds.checkBoxGrp( label="Modifiers",
							numberOfCheckBoxes=2,
							labelArray2=('Ctrl', 'Alt'),
							columnWidth3=(100, 75, 75))
radioButtonGrp = cmds.radioButtonGrp( label="Action",
							numberOfRadioButtons=2,
							select=1,
							labelArray2=('Press', 'Release'),
							columnWidth3=(100, 75, 75))

#    Create a scroll field for printing the results.
#
scrollField = cmds.scrollField(editable=False, height=120, wordWrap=True)

#    Create a button for querying the hotkey.
#
cmds.button( label='Query', command=('ExampleHotkeyCheck("' + textFieldGrp + '","' + checkBoxGrp + '","' + radioButtonGrp + '","' + scrollField + '")'))
cmds.showWindow( window )

#    This procedure uses the 'hotkeyCheck' command to determine the
#    annotation of the command attached to a hotkey.
#
def ExampleHotkeyCheck( textFieldGrp, checkBoxGrp, radioButtonGrp, scrollField):
	#    Get the hotkey character, modifier state and key press/release
	#    information from the window.
	#
	key = cmds.textFieldGrp(textFieldGrp, query=True, text=True)
	ctrl = cmds.checkBoxGrp(checkBoxGrp, query=True, value1=True)
	alt = cmds.checkBoxGrp(checkBoxGrp, query=True, value2=True)
	press = cmds.radioButtonGrp(radioButtonGrp, query=True, select=True)

	#    Get the hotkey mapping taking into consideration key up or down
	#    and the state of the modifier keys.
	#
	if 1 == press:
		if not ctrl and not alt:
			mapping = cmds.hotkeyCheck(keyString=key)
			result = key + '-Press'
		elif ctrl and not alt:
			mapping = cmds.hotkeyCheck(keyString=key, ctl=True)
			result = 'Ctrl-' + key + '-Press'
		elif not ctrl and alt:
			mapping = cmds.hotkeyCheck(keyString=key, alt=True)
			result = 'Alt-' + key + '-Press'
		elif ctrl and alt:
			mapping = cmds.hotkeyCheck(keyString=key, ctl=True, alt=True)
			result = 'Ctrl-Alt-' + key + '-Press'
	else:
		if not ctrl and not alt:
			mapping = cmds.hotkeyCheck(keyString=key, keyUp=True)
			result = key + '-Release'
		elif ctrl and not alt:
			mapping = cmds.hotkeyCheck(keyString=key, ctl=True, keyUp=True)
			result = 'Ctrl-' + key + '-Release'
		elif not ctrl and alt:
			mapping = cmds.hotkeyCheck(keyString=key, alt=True, keyUp=True)
			result = 'Alt-' + key + '-Release'
		elif ctrl and alt:
			mapping = cmds.hotkeyCheck(keyString=key, ctl=True, alt=True, keyUp=True)
			result = 'Ctrl-Alt-' + key + '-Release'


	#    Print the results in the example window.
	#
	if mapping == "": mapping = 'Nothing'
	cmds.scrollField( scrollField, edit=True, text=(result + ' is mapped to:\n\n' + mapping ) )