Difference between revisions of "Skinning How To/Edit a menu"

From Second Life Wiki
Jump to navigation Jump to search
 
(10 intermediate revisions by one other user not shown)
Line 5: Line 5:
* Example menu structure:
* Example menu structure:


<pre><menu>
<pre><menu_bar>
  <menu>
     <menu_item_call>
     <menu_item_call>
           <on_click>
           <on_click />
     </menu_item_call>
     </menu_item_call>
     <menu>  
     <menu>  
           <menu_item_check>  
           <menu_item_check>  
               <on_check>
               <on_check />
           </menu_item_check>
           </menu_item_check>
          <menu_item_separator />
           <menu_item_call>  
           <menu_item_call>  
               <on_click>
               <on_click />
               <on_enable>
               <on_enable />
           </menu_item_call>
           </menu_item_call>
     </menu>
     </menu>
</menu></pre>
  </menu>
</menu_bar></pre>
 
* For consistency, all layout settings are set in the '''\skins\default\xui\en-us''' folder. Other language folders contain translation strings.


== Menu files ==
== Menu files ==
Line 25: Line 30:
* Inventory menu: '''floater_inventory.xml'''
* Inventory menu: '''floater_inventory.xml'''
* Inventory item menu when right clicked: '''menu_inventory.xml'''
* Inventory item menu when right clicked: '''menu_inventory.xml'''
* Landmark menu when right clicked: '''menu_slurl.xml'''
* Script editor menu: '''floater_script_ed_panel.xml'''
* SLURL menu when right clicked (not currently enabled): '''menu_slurl.xml'''
* Menu at the login screen: '''menu_login.xml'''
* Menu at the login screen: '''menu_login.xml'''
* Pie menu when you right click:
* Pie menu when you right click:
Line 35: Line 41:


= Tags =
= Tags =
== <menu_bar> ==
Colored menu background. Optional. Accepts <code>name</code> and <code>opaque</code>.


== <menu> ==
== <menu> ==
Top level menu. Flyout menu when nested.
Top level menu. Flyout menu when nested.


== <menu_bar> ==
== <pie_menu> ==
Pie menu. Multiple pie menus when nested.


== <menu_item_call> ==
== <menu_item_call> ==
Menu item that tells the viewer to execute a specific function.  
Menu item that tells the viewer to execute a specific function.  


== <on_click> ==
== <menu_item_check> ==
Menu item that toggles whether something is active or inactive (set via an X next to the name).
 
== <on_click /> ==
Nested in a menu item. Sets the function when clicked.
Nested in a menu item. Sets the function when clicked.


== <on_enable> ==
== <on_enable /> ==
Nested in a menu item. Sets the function when option is enabled.  
Nested in a menu item. Sets the function when option is enabled.  


== <menu_item_separator> ==
== <on_check /> ==
Nested in a menu item. Sets the function when checked.
 
== <menu_item_separator /> ==
Draws a separator between menu options.
Draws a separator between menu options.
== <menu_item_check> ==
Menu item that toggles whether something is active or inactive (set via an X next to the name).
== <on_check> ==
Nested in a menu item. Sets the function when checked.


== <tearoff_menu> ==
== <tearoff_menu> ==
Line 64: Line 73:


= Parameters =
= Parameters =
Parameters define how a menu item is used. For example, this is the menu item to "Close All Windows":
<pre><menu_item_call
          bottom="-113"
          enabled="true"
          height="19"
          label="Close All Windows"
          left="0"
          mouse_opaque="true"
          name="Close All Windows"
          shortcut="control|shift|W"
          width="243">
          <on_click
              function="File.CloseAllWindows"
              userdata="" />
          <on_enable
              function="File.EnableCloseAllWindows"
              userdata="" /></menu_item_call></pre>
Valid parameters:


== enabled ==
== enabled ==
Sets whether or not a menu is enabled or not. Use in <menu>.  
Sets whether or not a menu is enabled or not. Use in <menu>.  
Boolean: <code>enabled="true"</code>
Boolean: <code>enabled="true"</code> (Default true)
== label ==
== label ==
Sets the name the user sees. Necessary for <menu> and menu items.  
Sets the name the user sees. Necessary for <menu> and menu items.  
Line 75: Line 105:
String: <code>name="MenuAwesome"</code>
String: <code>name="MenuAwesome"</code>
* Changing the name of the Tools menu will make it not auto-hide.
* Changing the name of the Tools menu will make it not auto-hide.
== tear_off ==
== tear_off ==
''Optional''. Sets whether or not the menu can be torn off (the double bars at the top of a menu).  Use in <menu>.   
''Optional''. Sets whether or not the menu can be torn off (the double bars at the top of a menu).  Use in <menu>.   
Boolean: <code>tear_off="true"</code>
Boolean: <code>tear_off="true"</code> (Default true)
== opaque ==
== opaque ==
''Optional''. Sets whether or not the menu is opaque (setting a stop level menu to false will turn the entire menu transparent unless torn off and reattached. Setting the menu bar to false will turn it transparent per settings in colors.xml). Use in <menu>.  
''Optional''. Sets whether or not the menu is opaque Setting a top-level menu like World to false turns the menu transparent (unless it's torn off and reattached, then you have to relog). Setting the menu bar to false will turn it transparent per its setting in colors.xml. Use in <menu> and <menu_bar>.  
Boolean: <code>opaque="true"</code>
Boolean: <code>opaque="true"</code>
== mouse_opaque ==
== mouse_opaque ==
== drop_shadow ==
== drop_shadow ==
Default.
== create_jump_keys ==
== create_jump_keys ==
''Optional''. Allows keyboard navigation via jump keys. Menus can be navigated using the keyboard by holding down ALT and pressing up or down.
Boolean: <code>create_jump_keys="true"</code>
== userdata ==
== userdata ==
''Optional''. Any data sent to the function. Use in <on_click>, etc.
''Optional''. Any data sent to the function. Use in <on_click>, etc.
Line 95: Line 127:
String: <code>shortcut="control|alt|T"</code>
String: <code>shortcut="control|alt|T"</code>


= Changing a menu =
= Moving menu items =
 
Most all of the menu items in the menu*.xml files can be placed in other menu*.xml files (there are some exceptions). For example, you can move return from the pie menu to the Tools menu, or Link from tools to the pie.
 
To do so, simply copy the <code><menu_item /></code> tag and its essential parameters from one file to the other.
 
Note that in the pie menu, empty slices are defined by a <code><menu_item_separator /></code> tag.
 
= Useful Tips =
* If you're adding a shortcut, make sure it isn't used by another item first.
* If you're adding a shortcut, make sure it isn't used by another item first.
* Renaming a menu or menu item is fine as long as it calls a working function.  
* Don't change a menu's <code>name=</code> value. This is used in translation.
* Renaming a menu's label is fine as long as it calls a working function.  
* Any number of top level menus, flyout menus, and menu items can be set.  
* Any number of top level menus, flyout menus, and menu items can be set.  
* Don't worry about width/height/bottom/left/top. As said in the intro, these don't do anything anymore.  
* Don't worry about width/height/bottom/left/top. As said in the intro, these don't do anything anymore.  

Latest revision as of 22:28, 30 November 2023

Introduction

  • All viewer menu options are set in menu_viewer.xml except for the Advanced/Admin menus (see VWR-2896).
  • Width/height/bottom/left/top are irrelevant in the menu files. The viewer constructs menus based on the xml file's organization and ignores these parameters.
  • Example menu structure:
<menu_bar>
  <menu>
     <menu_item_call>
          <on_click />
     </menu_item_call>
     <menu> 
          <menu_item_check> 
               <on_check />
          </menu_item_check>
          <menu_item_separator />
          <menu_item_call> 
               <on_click />
               <on_enable />
          </menu_item_call>
     </menu>
  </menu>
</menu_bar>
  • For consistency, all layout settings are set in the \skins\default\xui\en-us folder. Other language folders contain translation strings.

Menu files

  • Viewer menu: menu_viewer.xml
  • Inventory menu: floater_inventory.xml
  • Inventory item menu when right clicked: menu_inventory.xml
  • Script editor menu: floater_script_ed_panel.xml
  • SLURL menu when right clicked (not currently enabled): menu_slurl.xml
  • Menu at the login screen: menu_login.xml
  • Pie menu when you right click:
    • An object: menu_pie_object.xml
    • Yourself: menu_pie_self.xml
    • Land: menu_pie_land.xml
    • Someone else: menu_pie_avatar.xml
    • An attachment: menu_pie_attachment.xml

Tags

<menu_bar>

Colored menu background. Optional. Accepts name and opaque.

<menu>

Top level menu. Flyout menu when nested.

<pie_menu>

Pie menu. Multiple pie menus when nested.

<menu_item_call>

Menu item that tells the viewer to execute a specific function.

<menu_item_check>

Menu item that toggles whether something is active or inactive (set via an X next to the name).

<on_click />

Nested in a menu item. Sets the function when clicked.

<on_enable />

Nested in a menu item. Sets the function when option is enabled.

<on_check />

Nested in a menu item. Sets the function when checked.

<menu_item_separator />

Draws a separator between menu options.

<tearoff_menu>

Does nothing. Assumed to be a legacy setting.


Parameters

Parameters define how a menu item is used. For example, this is the menu item to "Close All Windows":

<menu_item_call
           bottom="-113"
           enabled="true"
           height="19"
           label="Close All Windows"
           left="0"
           mouse_opaque="true"
           name="Close All Windows"
           shortcut="control|shift|W"
           width="243">
           <on_click
               function="File.CloseAllWindows"
               userdata="" />
           <on_enable
               function="File.EnableCloseAllWindows"
               userdata="" /></menu_item_call>

Valid parameters:

enabled

Sets whether or not a menu is enabled or not. Use in <menu>. Boolean: enabled="true" (Default true)

label

Sets the name the user sees. Necessary for <menu> and menu items. String: label="Awesome Menu"

name

Sets the name the viewer sees. Necessary for <menu> and menu items. String: name="MenuAwesome"

  • Changing the name of the Tools menu will make it not auto-hide.

tear_off

Optional. Sets whether or not the menu can be torn off (the double bars at the top of a menu). Use in <menu>. Boolean: tear_off="true" (Default true)

opaque

Optional. Sets whether or not the menu is opaque Setting a top-level menu like World to false turns the menu transparent (unless it's torn off and reattached, then you have to relog). Setting the menu bar to false will turn it transparent per its setting in colors.xml. Use in <menu> and <menu_bar>. Boolean: opaque="true"

mouse_opaque

drop_shadow

Default.

create_jump_keys

Optional. Allows keyboard navigation via jump keys. Menus can be navigated using the keyboard by holding down ALT and pressing up or down. Boolean: create_jump_keys="true"

userdata

Optional. Any data sent to the function. Use in <on_click>, etc. String: userdata="800,600"

function

Associates a function with a menu item and action. Use in <on_click>, etc. String: function="Tools.SelectedScriptAction"

shortcut

Optional. Sets the keyboard shortcut for a menu item. Each key is separated by pipes. String: shortcut="control|alt|T"

Moving menu items

Most all of the menu items in the menu*.xml files can be placed in other menu*.xml files (there are some exceptions). For example, you can move return from the pie menu to the Tools menu, or Link from tools to the pie.

To do so, simply copy the <menu_item /> tag and its essential parameters from one file to the other.

Note that in the pie menu, empty slices are defined by a <menu_item_separator /> tag.

Useful Tips

  • If you're adding a shortcut, make sure it isn't used by another item first.
  • Don't change a menu's name= value. This is used in translation.
  • Renaming a menu's label is fine as long as it calls a working function.
  • Any number of top level menus, flyout menus, and menu items can be set.
  • Don't worry about width/height/bottom/left/top. As said in the intro, these don't do anything anymore.
  • If you want to create a new menu item that doesn't call an existing function, you need to edit the source as well. See Adding_a_menu_item for a start.