File: MainMenu.schelp

package info (click to toggle)
supercollider 1%3A3.10.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 45,496 kB
  • sloc: cpp: 283,513; lisp: 74,040; ansic: 72,252; sh: 23,016; python: 7,175; makefile: 1,087; perl: 766; java: 677; yacc: 314; lex: 175; ruby: 136; objc: 65; xml: 15
file content (102 lines) | stat: -rw-r--r-- 3,696 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
TITLE:: MainMenu
summary:: A manager for sclang's application-level menu
categories:: GUI
related:: Classes/MenuAction, Classes/ToolBar, Classes/MainMenu

DESCRIPTION::
This class allows control over items displayed in the sclang application-level menu. Application-level menus may not exist depending on platform — in particular, macOS and some Linux window managers have it, but Windows does not. On platforms without this feature, the methods in this class simply don't do anything.

note:: This is the menu for the sclang application, not the IDE. ::

CODE::
(
~testTone = MenuAction("Test Tone", {
	{ SinOsc.ar(400) * 0.1 }.play;
});

MainMenu.register(~testTone, "Tests");

// MainMenu.unregister(~testTone); // to remove
)
::

CLASSMETHODS::

METHOD:: register
	Register a MenuAction to a main application menu. This menu item will exist for the duration of the app, or until .unregister is called for the action.

	ARGUMENT:: action
		A link::Classes/MenuAction::.
	ARGUMENT:: menu
		A String, representing the name of the top-level menu to contain the action.
	ARGUMENT:: group
		An optional string. Action will be placed in a section of the menu with other members of the same group, with a separator between items of other groups.

	DISCUSSION::
		MainMenu.register provides an easy way to register global menu items, in a way that helps avoid disrupting menus registered by other SuperCollider components.

		If you want to register menus for personal use, add the registration calls to your startup.scd file. This will ensure the menus are created automatically on launch.

		If you're registering menu actions for a Quark or other component intended for distribution, be sure to be polite and thoughtful about where you're registering actions.

		Avoid creating new top-level menus if possible - instead, try to use one of the following canonical menus to register your actions. Add your actions to a group to ensure you don't collide with actions from another component:
		LIST::
			## File
			## Edit
			## Server
			## Quarks
			## Help
		::

		If registering menu items for a Quark, consider registering as a sub-menu of the Quarks menu. This can easily be done using the link::Classes/MainMenu#registerQuarkMenu:: method.

METHOD:: registerQuarkMenu
	Convenience method for registering a menu of functionality related to a Quark.
	It will appear as a sub-menu under the main Quarks menu.

	ARGUMENT:: quarkName
		A String, the name of the quark
	ARGUMENT:: menu
		A link::Classes/Menu::, a menu.

METHOD:: unregister
	Remove a MenuAction that has been registered previously.
	NOTE::
		It is usually disruptive and confusing to add and remove menu items dynamically.
		If you're registering a menu item that should only sometimes be available, consider disabling it using code::menuAction.enabled = false;:: rather than removing it.
	::

	ARGUMENT::
		A MenuAction.

METHOD:: otherMenus
	A list of menus to append to the set of main application menus.

	WARNING::This is intended for standalone SuperCollider applications, and should not be used to register menus during normal SC usage.::

METHOD:: applicationMenu
	The main SuperCollider application menu.

	WARNING::This is intended for standalone SuperCollider applications, and should not be used to register menus during normal SC usage.::

EXAMPLES::

code::
(
~show = MenuAction("Show Window", {
	~window ?? {
		~window = TextView().string_("Here it goes!").minSize_(300@200);
		~window.onClose = { ~window = nil };
		~window.front;
	}
});
~hide = MenuAction("Hide Window", {
	~window !? {
		~window.close();
		~window = nil;
	}
});

MainMenu.register(Menu(~show, ~hide).title_("My Quark"), "Quarks", "My Quark")
)
::