About
Menus are fairly explanatory in name, they hold options and fold out. Currently there is no way to add the Menu as a simple control and only the MainMenu? and ContextMenu? exist.
Usage
Menus are all about their MenuItems?. A Menu merely contains all the menuItems, it does not represent text or anything else. Luckily there are good things to Menus thanks to DFL. Mainly, things just work. All MenuItems? are Menus and as such you can add other MenuItems? to their menuItems collection and it makes the MenuItem? into a Menu with options inside of it. This makes sense to have MenuItems? represent Menus since the Menu itself may need to be clicked.
Shortcuts
To add mnemonics just put '&' in front of the character to use as a mnemonic in the MenuItem?'s text. In order to use Accelerators (eg. "Ctrl+S") please refer to Form.addShortcut.
Breaks
To introduce a bar break do not set the text, set the text to "-", or set barBreak to true.
Example
import dfl.all;
public void main() {
auto form = new Form();
form.text = "Menu Example";
auto menu = new MainMenu();
form.menu = menu;
auto currentMenu = new MenuItem("File");
menu.menuItems.add(currentMenu);
auto currentItem = new MenuItem("&New");
currentMenu.menuItems.add(currentItem);
currentItem = new MenuItem("Recent");
currentMenu.menuItems.add(currentItem);
currentMenu = currentItem;
currentItem = new MenuItem("File");
currentMenu.menuItems.add(currentItem);
currentItem = new MenuItem("Project");
currentMenu.menuItems.add(currentItem);
currentMenu = cast(MenuItem)currentMenu.parent;
currentItem = new MenuItem();
currentItem.barBreak = true;
currentMenu.menuItems.add(currentItem);
currentItem = new MenuItem("Exit");
currentMenu.menuItems.add(currentItem);
currentItem = new MenuItem("Side Option");
currentItem.breakItem = true;
currentItem.checked = true;
currentMenu.menuItems.add(currentItem);
Application.run(form);
}
module dfl.menu;
{
public final void show(Control control,Point pos);
Inherited members
}
{
public void add(char[] value);
public void add(MenuItem mi);
public void add(char[] s);
public void insert(int index,char[] s);
}
{
Inherited members
handle
isParent
MenuItemCollection
menuItems
onReflectedMessage
tag
}
{
public void add(char[] value);
public void add(MenuItem mi);
public void add(char[] s);
public void insert(int index,char[] s);
}
{
public final HMENU handle;
[property getter]
public final MenuItemCollection menuItems;
[property getter]
public final Object tag;
[property getter]
public final Object tag;
[property setter]
}
{
public void add(char[] value);
public void add(MenuItem mi);
public void add(char[] s);
public void insert(int index,char[] s);
}
{
public final bool barBreak;
[property setter]
public final bool barBreak;
[property getter]
public final bool breakItem;
[property setter]
public final bool breakItem;
[property getter]
public final bool checked;
[property getter]
public final bool checked;
[property setter]
public final bool enabled;
[property setter]
public final bool enabled;
[property getter]
public final int index;
[property setter]
public final int index;
[property getter]
protected final int menuID;
[property getter]
public final char mnemonic;
[property getter]
protected void onClick(EventArgs ea);
protected void onPopup(EventArgs ea);
public int opCmp(char[] val);
public int opCmp(Object o);
public final Menu parent;
[property setter]
public final Menu parent;
[property getter]
public final char[] text;
[property getter]
public final char[] text;
[property setter]
Inherited members
}
{
public void add(char[] value);
public void add(MenuItem mi);
public void add(char[] s);
public void insert(int index,char[] s);
}