移動先: 概要 戻り値 フラグ. Python 例.

概要

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

注意: オブジェクト名や引数を表す文字列はカンマで区切ります。これは概要には示されていません。

hotkeyCheck は 「元に戻す」が可能、「照会」が不可能「編集」が不可能 です。

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

戻り値

stringnameCommand オブジェクトの注釈または空の文字列。

フラグ

altModifier, commandModifier, ctrlModifier, keyString, keyUp, optionModifier
ロング ネーム(ショート ネーム) 引数型 プロパティ
keyString(k) string create
チェックするキーです。
altModifier(alt) boolean create
Alt キーを押すかどうかを指定します。
optionModifier(opt) boolean create
option キーを押すかどうかを指定します。
commandModifier(cmd) boolean create
コマンド キーを押すかどうかを指定します。
ctrlModifier(ctl) boolean create
Ctrl キーを押すかどうかを指定します。
keyUp(kup) boolean create
ホットキーをキーアップまたはキーダウンにするか(つまり離すか押すか)を指定します。

: コマンドの作成モードで使用可能なフラグ : コマンドの編集モードで使用可能なフラグ
: コマンドの照会モードで使用可能なフラグ : タプルまたはリストとして渡された複数の引数を持てるフラグ

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 ) )