Ueta CG Tech (blog)

Maya・MotionBuilderツール開発/ゲーム開発支援/映像制作支援/各種テクニカルスタッフ代行

【Maya】PySideやPyQtで作ったツールのテキスト入力欄にうまくコピペできない問題

タイトルのまんまなのですが、つまりどういうことなのか、画像で説明いたします。

f:id:ue_ta:20150131170742p:plain

フォーカスが外れたことに気がつかないまま数値や文字列などをコピペしちゃうと、 Mayaに変なオブジェクトが追加されてしまいます。 (おそらく、昔コピーしたなんらかのノードとかです)

私は、この現象に対して、今までは KeyPressEvent をオーバーライドしたりして対応したつもりでいましたが、どうやら勘違いだったようです。

正しい(?)解決策がリリースノートにありましたのでご紹介いたします。

http://download.autodesk.com/us/maya/pdfs/2014/Maya2014_Readme_jpn.html

[MAYA-20292]
Need option to prevent hotkeys from giving focus to panels under the current window in focus
Set MAYA_FORCE_PANEL_FOCUS to 0 so that when you have a Maya or Qt window over another window with a model panel (or a window such as the Outliner, Graph Editor, or any panel under Panels > Panel), hitting the Shift key does not cause the model panel's window to steal focus.

The default value of this variable is 1.

When this environment variable is set to 0, clicking a hotkey only affects the workspace that has focus. If you want to use the hotkey with a different workspace, you may need to click on the workspace to bring focus to that area before your hotkey takes effect.

環境変数を設定するだけで意図する動作になりました。

set MAYA_FORCE_PANEL_FOCUS=0

ただ、ショートカットキーの影響がフォーカスされているワークスペース(ウインドウ?)に限定される?というのがいまいち再現できません。

たとえばフローティングのアウトライナにフォーカスした状態で、ショートカット[Alt+.]「次のフレームへ移動」を押すと正しく動作します。問題なさそうですが、念のためご自身の環境でテストしていただければと思います。