<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.spheredev.org/index.php?action=history&amp;feed=atom&amp;title=Script%3ASystem%2Fmenu.js</id>
	<title>Script:System/menu.js - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.spheredev.org/index.php?action=history&amp;feed=atom&amp;title=Script%3ASystem%2Fmenu.js"/>
	<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=Script:System/menu.js&amp;action=history"/>
	<updated>2026-11-24T22:49:14Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>http://wiki.spheredev.org/index.php?title=Script:System/menu.js&amp;diff=1001&amp;oldid=prev</id>
		<title>Apollolux: created from http://web.archive.org/web/20111117214905/http://www.spheredev.org/wiki/Menu.js_(system_script)</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=Script:System/menu.js&amp;diff=1001&amp;oldid=prev"/>
		<updated>2013-08-02T20:22:39Z</updated>

		<summary type="html">&lt;p&gt;created from http://web.archive.org/web/20111117214905/http://www.spheredev.org/wiki/Menu.js_(system_script)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The [[Script:system|system script]] [[Script:system/menu.js|menu.js]] provides a simple menu object.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
{{usage|func=[[API:RequireSystemScript|RequireSystemScript]]|params=&amp;quot;menu.js&amp;quot;}}&lt;br /&gt;
&lt;br /&gt;
==Variables and functions of menu.js==&lt;br /&gt;
*	object constructor &amp;#039;&amp;#039;&amp;#039;Menu()&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
**	properties of objects of Menu type:&lt;br /&gt;
***	&amp;#039;&amp;#039;&amp;#039;font&amp;#039;&amp;#039;&amp;#039; - a [[API:Font|font object]] used by the menu. Defaults to the [[API:GetSystemFont|system font]] if not specified.&lt;br /&gt;
***	&amp;#039;&amp;#039;&amp;#039;window_style&amp;#039;&amp;#039;&amp;#039; - a [[API:WindowStyle|window style object]] used as a menu background. Defaults to the [[API:GetSystemWindowStyle|system window style]] if not specified.&lt;br /&gt;
***	&amp;#039;&amp;#039;&amp;#039;arrow&amp;#039;&amp;#039;&amp;#039; - an [[API:Image|image object]] representing the menu arrow image. Defaults to the [[API:GetSystemArrow|system arrow]] if not specified.&lt;br /&gt;
***	&amp;#039;&amp;#039;&amp;#039;up_arrow&amp;#039;&amp;#039;&amp;#039; - an [[API:Image|image object]] to be used as an up arrow if the menu content exceeds the window. Defaults to the [[API:GetSystemUpArrow|system up arrow]] if not specified.&lt;br /&gt;
***	&amp;#039;&amp;#039;&amp;#039;down_arrow&amp;#039;&amp;#039;&amp;#039; - an [[API:Image|image object]] to be used as a down arrow if the menu content exceeds the window. Defaults to the [[API:GetSystemDownArrow|system down arrow]] if not specified.&lt;br /&gt;
***	&amp;#039;&amp;#039;&amp;#039;escape_function&amp;#039;&amp;#039;&amp;#039; - a function to be called when the escape key is pressed.&lt;br /&gt;
**	methods of objects of Menu type:&lt;br /&gt;
***	&amp;#039;&amp;#039;&amp;#039;addItem(name, callback [, color])&amp;#039;&amp;#039;&amp;#039; - adds an entry to the menu. The string &amp;#039;name&amp;#039; specifies the menu text, &amp;#039;callback&amp;#039; is a function to be called when the item is selected and &amp;#039;color&amp;#039; is a [[API:Color|color object]] defining the color of the item. If the color remains unspecified it is set to white.&lt;br /&gt;
***	&amp;#039;&amp;#039;&amp;#039;execute(x, y, width, height)&amp;#039;&amp;#039;&amp;#039; - this displays and executes the menu. The arguments &amp;#039;x&amp;#039;, &amp;#039;y&amp;#039;, &amp;#039;width&amp;#039; and &amp;#039;height&amp;#039; define the size of the menu window. If the menu items don&amp;#039;t fit into the window, the menu will be scrollable.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
RequireSystemScript(&amp;quot;menu.js&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
var MainMenu = new Menu();&lt;br /&gt;
MainMenu.addItem(&amp;quot;Items&amp;quot;, ItemMenu);&lt;br /&gt;
MainMenu.addItem(&amp;quot;Equip&amp;quot;, EquipMenu);&lt;br /&gt;
MainMenu.addItem(&amp;quot;Magic&amp;quot;, MagicMenu);&lt;br /&gt;
MainMenu.addItem(&amp;quot;Stats&amp;quot;, StatsMenu);&lt;br /&gt;
MainMenu.addItem(&amp;quot;Quit&amp;quot;, Exit);&lt;br /&gt;
&lt;br /&gt;
MainMenu.execute(20, 20, 50, 60);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following functions are called if their respective menu item is selected. They have to be defined for the above to work. [[API:Exit|Exit]](), which is called by the last menu item, doesn&amp;#039;t need to be defined, because it is a function of the [[API:Functions|Sphere API]].&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
function ItemMenu() {&lt;br /&gt;
  //...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function EquipMenu() {&lt;br /&gt;
  //...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
function MagicMenu() {&lt;br /&gt;
  //...&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
function StatsMenu() {&lt;br /&gt;
  //...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
*	The menu arrow is moved using the up and down directional keys. A selection is always confirmed with enter. Joystick input is not supported.&lt;br /&gt;
*	If necessary the up and down arrows will be displayed near the right border of the menu window.&lt;br /&gt;
*	To specify a function as an &amp;lt;var&amp;gt;escape_function&amp;lt;/var&amp;gt; or &amp;lt;var&amp;gt;callback&amp;lt;/var&amp;gt; function you may &amp;#039;&amp;#039;not&amp;#039;&amp;#039; use brackets.&amp;lt;br/&amp;gt;&amp;lt;pre&amp;gt;/* This won&amp;#039;t work:     */&amp;amp;#10;MyMenu.escape_function = DoSomething();&amp;amp;#10;MyMenu.addItem(&amp;quot;New Game&amp;quot;, NewGame());&amp;lt;/pre&amp;gt;&amp;lt;pre&amp;gt;/* This will work fine: */&amp;amp;#10;MyMenu.escape_function = DoSomething;&amp;amp;#10;MyMenu.addItem(&amp;quot;New Game&amp;quot;, NewGame);&amp;lt;/pre&amp;gt;&lt;br /&gt;
*	Menu.js automatically includes the [[Script:System/colors.js|system script colors.js]].&lt;br /&gt;
*	A tutorial can be found in the {{dir|docs/system_scripts/}} directory of Sphere.&lt;br /&gt;
*	The famous [[Script:flik_menu.js|flik_menu.js]] is not a system script, but works similar to menu.js. It allows you to do much more though.&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
*	[http://sphere.sourceforge.net/flik/docs/sphere-menu.html Flik&amp;#039;s Sphere Central &amp;amp;rarr; Docs : How to use Sphere&amp;#039;s default menu object].&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripts]]&lt;/div&gt;</summary>
		<author><name>Apollolux</name></author>
	</entry>
</feed>