//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
//**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************//
using System;
using bs;
namespace bs.Editor
{
/** @addtogroup Window
* @{
*/
///
/// Adds an entry to the main menu bar. Clicking on that entry will trigger the method the attribute is attached to.
/// The method must be static, have no parameters or return values otherwise the attribute will be ignored.
///
[AttributeUsage(AttributeTargets.Method)]
public sealed class MenuItem : Attribute
{
///
/// Creates a new menu item attribute with a shortcut. Pressing the shortcut key or selecting the item in the menu
/// will trigger the menu item callback.
///
/// Path that determines where in the menu to add the element. All path elements must be
/// separated by /, for example "View/Toolbars/Find".
/// Optional shortcut modifier that needs to be pressed along with the shortcut
/// button in order to trigger the shortcut.
/// Shortcut key that will trigger the shortcut.
/// Priority determines the position of the menu item relative to its siblings.
/// Higher priority means it will be placed earlier in the menu.
/// Determines should a separator be inserted just before this element.
/// Name of a method that returns a boolean determining whether the menu item callback
/// is allowed to trigger. This is useful if menu items are only valid in specific
/// situations (for example a scene object must be selected). The method must be
/// static, return a boolean value, accept no parameters and be in the same class as
/// the method this attribute is attached to.
public MenuItem(string path, ButtonModifier shortcutModifier, ButtonCode shortcutKey, int priority = 0,
bool separator = false, string contextCallback = null)
{
this.path = path;
this.shortcut = new ShortcutKey(shortcutModifier, shortcutKey);
this.priority = priority;
this.separator = separator;
this.contextCallback = contextCallback;
}
///
/// Creates a new menu item attribute. Selecting the item in the menu will trigger the menu item callback.
///
/// Path that determines where in the menu to add the element. All path elements must be
/// separated by /, for example "View/Toolbars/Find".
/// Priority determines the position of the menu item relative to its siblings.
/// Higher priority means it will be placed earlier in the menu.
/// Determines should a separator be inserted just before this element.
/// Name of a method that returns a boolean determining whether the menu item callback
/// is allowed to trigger. This is useful if menu items are only valid in specific
/// situations (for example a scene object must be selected). The method must be
/// static, return a boolean value, accept no parameters and be in the same class as
/// the method this attribute is attached to.
public MenuItem(string path, int priority = 0, bool separator = false, string contextCallback = null)
{
this.path = path;
this.priority = priority;
this.separator = separator;
this.contextCallback = contextCallback;
}
#pragma warning disable 0414
private string path;
private ShortcutKey shortcut;
private int priority;
private bool separator;
private string contextCallback;
#pragma warning restore 0414
}
/** @} */
}