ActionMenu[name,{lbl1:>act1,lbl2:>act2,…}]
対応する項目が選ばれると式 actiを評価する lbliというラベルの付いた項目を含む,name というラベルの付いたアクションメニューを表す.
ActionMenu[name,{…,lbli{sublbl1:>subact1,sublbl2:>subact2,…},…}]
アクションが subactiの項目 sublbliを含む,ラベル lbliが付いたサブメニューを含むアクションメニューを表す.
ActionMenu
ActionMenu[name,{lbl1:>act1,lbl2:>act2,…}]
対応する項目が選ばれると式 actiを評価する lbliというラベルの付いた項目を含む,name というラベルの付いたアクションメニューを表す.
ActionMenu[name,{…,lbli{sublbl1:>subact1,sublbl2:>subact2,…},…}]
アクションが subactiの項目 sublbliを含む,ラベル lbliが付いたサブメニューを含むアクションメニューを表す.
詳細とオプション
- name,サブメニュー,項目ラベルは任意の式でよい.
- ActionMenuは,デフォルトで name と lbliを"ActionMenu"スタイルで表示する.通常はシステムのメニューフォントが使われる.
- ActionMenu[name,list]では,list の要素としてDelimiterを使い,表示されたメニューの水平デリミタを指定することができる.
- サブメニューはデリミタおよび他のサブメニューを含むことができる.
- 次のオプションを与えることができる.
-
Appearance Automatic メニューの全体的な外観 BaselinePosition Automatic 周囲のテキストのベースラインと何を揃えるか BaseStyle {} メニューのベーススタイル指定 ContentPadding True 余白をコンテンツの周囲ぎりぎりまで縮めるかどうか Enabled Automatic メニューを有効にするか,灰色(無効)にするか Evaluator Automatic actiを評価するカーネル FrameMargins Automatic メニューの枠の中に残す余白 ImageMargins 0 表示されたメニューの画像周囲の余白 ImageSize Automatic 表示されたメニューの全体的な画像サイズ MenuStyle {} メニュー項目のスタイル指定 Method "Preemptive" 使用する評価メソッド - Appearanceが取り得る値には次のようなものがある.
-
None 編集を加えずに name だけを表示する Automatic 特別のアクションメニュー形式で表示する(デフォルト) "PopupMenu" 初期値を name とし,ポップアップメニューのように表示する "Button" ボタンのように表示する - Methodオプションの一般的な設定値には"Preemptive","Queued"等がある.
- BaseStyleの設定値は,一般に現行スタイルシートの"ActionMenu"スタイルで与えられるデフォルトスタイルに付加される.
例題
すべて開く すべて閉じる例 (3)
ActionMenu["階乗の表示", {"4!" :> Print[4!], "7!" :> Print[7!], "10!" :> Print[10!]}]{ActionMenu["xの設定", {"x = 1" :> (x = 1;), "x = 2" :> (x = 2;)}], Dynamic[x]}ActionMenu["出力", {"階乗の出力" -> {"4!" :> Print[4!], "7!" :> Print[7!], "10!" :> Print[10!]}, "二重階乗の出力" -> {"4!!" :> Print[4!!], "7!!" :> Print[7!!], "10!!" :> Print[10!!]}}]スコープ (3)
Delimiterを使ってメニュー項目を分離する:
{ActionMenu["xの設定", {"x = 1" :> (x = 1;), Delimiter, "x = 2" :> (x = 2;)}], Dynamic[x]}{ActionMenu["xの設定", {Graphics[Disk[], ImageSize -> 20] :> (x = 1;), Delimiter, Expand[(a + b) ^ 4] :> (x = 2;)}], Dynamic[x]}ActionMenu["Help", {
"Version Information" -> {"Kernel" :> Print[$Version], "All" :> NotebookPut[SystemInformation[]]},
"Documentation" -> {
"Home" :> FrontEndTokenExecute[EvaluationNotebook[], "OpenHelpLink"],
Delimiter,
"$Version" :> SystemOpen["paclet:ref/$Version"], "SystemInformation" :> SystemOpen["paclet:ref/SystemInformation"]} }]オプション (10)
Appearance (1)
ContentPadding (1)
Enabled (2)
デフォルトで,ActionMenuは有効になっている:
ActionMenu["階乗", {"4!" :> Print[4!], "7!" :> Print[7!], "10!" :> Print[10!]}]Enabled->Falseと設定すると,このメニュー項目は無効になる:
ActionMenu["階乗", {"4!" :> Print[4!], "7!" :> Print[7!], "10!" :> Print[10!]}, Enabled -> False]Evaluator (2)
ActionMenu["カーネル", {"$ProcessID" :> Print[$ProcessID], "$SessionID" :> Print[$SessionID]}]Evaluatorを設定すると,ボタン関数を別のカーネルで評価することができる:
ActionMenu["フロントエンド", {"$ProcessID" :> Print[$ProcessID], "$SessionID" :> Print[$SessionID]}, Evaluator -> "System"]FrameMargins (1)
ImageMargins (1)
ImageSize (1)
Method (1)
デフォルトで,アクションメニュー関数は5秒でタイムアウトになるプリエンプティブリンクで評価される:
DynamicModule[{a = "開始"},
{ActionMenu["タイムアウト",
{"時間がかかるタスク" :> (Pause[10];a = "end long task"),
"もっと時間がかかるタスク" :> (Pause[20];a = "end longer task")}
], Dynamic[a]}]Method->"Queued"を使ってボタン関数をタイムアウトがないメインリンクで評価するようにする:
DynamicModule[{a = "開始"},
{ActionMenu["タイムアウトなし",
{"時間がかかるタスク" :> (Pause[10];a = "end long task"),
"もっと時間がかかるタスク" :> (Pause[20];a = "end longer task")},
Method -> "Queued"
], Dynamic[a]}]アプリケーション (2)
{g1, g2, g3, g4} = {Graphics[Disk[], ImageSize -> 20], Graphics[Circle[], ImageSize -> 20], Graphics[Rectangle[], ImageSize -> 20], Graphics[Polygon[{{-1, 0}, {1, 0}, {0, Sqrt[3]}}], ImageSize -> 20]};DynamicModule[{x = {}},
{ActionMenu["Graphics", {g1 :> (x = Disk[];), g2 :> (x = Circle[];),
g3 :> (x = Rectangle[];),
g4 :> (x = Polygon[{{-1, 0}, {1, 0}, {0, Sqrt[3]}}];)}], Dynamic[Graphics[{Pink, x}]]}]DynamicModule[{range = 1}, Column[{ActionMenu["ズーム", {"イン" :> (range = range 3 / 4), "アウト" :> (range = range 4 / 3), "リセット" :> (range = 1)}], Graphics[{Circle[{0, 0}, #]& /@ {1 / 5, 1 / 2, 1, 5, 10}}, Axes -> True, PlotRange -> Dynamic[range]]}]]特性と関係 (1)
ActionMenuは一連のButtonと同じ効果を持つ:
{ActionMenu["xの設定", {"x = 1" :> (x = 1;), "x = 2" :> (x = 2;)}], Dynamic[x]}{Button["y = 1", (y = 1;)], Button["y = 2", (y = 2;)], Dynamic[y]}おもしろい例題 (1)
menus = Get[FileNameJoin[{$InstallationDirectory, "SystemFiles/FrontEnd/TextResources/Japanese", $InterfaceEnvironment, "MenuSetup.tr"}]][[2]];メニューをActionMenuで配備可能な形式に変換する:
menus = menus //. {MenuItem[lbl_, action_String, ___] :> (lbl :> FrontEndTokenExecute[action]),
MenuItem[lbl_, action_, ___] :> (lbl :> action), (HelpMenu | Menu)[lbl_, submenu_List, ___] :> (lbl -> submenu),
LinkedItems[{name_ :> _, ___}] :> (name :> Null),
AlternateItems[{first_, ___}] :> first};
ActionMenu["Main menu", menus]テクニカルノート
関連するガイド
テキスト
Wolfram Research (2007), ActionMenu, Wolfram言語関数, https://reference.wolfram.com/language/ref/ActionMenu.html (2023年に更新).
CMS
Wolfram Language. 2007. "ActionMenu." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2023. https://reference.wolfram.com/language/ref/ActionMenu.html.
APA
Wolfram Language. (2007). ActionMenu. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ActionMenu.html
BibTeX
@misc{reference.wolfram_2026_actionmenu, author="Wolfram Research", title="{ActionMenu}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/ActionMenu.html}", note=[Accessed: 11-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_actionmenu, organization={Wolfram Research}, title={ActionMenu}, year={2023}, url={https://reference.wolfram.com/language/ref/ActionMenu.html}, note=[Accessed: 11-September-2026]}