*
* The MIT License (MIT)
*
- * Copyright (C) 2017 Kevin Lamonte
+ * Copyright (C) 2019 Kevin Lamonte
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
/**
* TMenu is a top-level collection of TMenuItems.
*/
-public final class TMenu extends TWindow {
+public class TMenu extends TWindow {
/**
* Translated strings.
* @param x column relative to parent
* @param y row relative to parent
* @param label mnemonic menu title. Label must contain a keyboard
- * shortcut (mnemonic), denoted by prefixing a letter with "&",
- * e.g. "&File"
+ * shortcut (mnemonic), denoted by prefixing a letter with "&",
+ * e.g. "&File"
*/
public TMenu(final TApplication parent, final int x, final int y,
final String label) {
@Override
public void onMouseDown(final TMouseEvent mouse) {
this.mouse = mouse;
+ super.onMouseDown(mouse);
// Pass to children
for (TWidget widget: getChildren()) {
hLineXY(1 + 1, getHeight() - 1, getWidth() - 4, cHSide, background);
// Draw a shadow
- getScreen().drawBoxShadow(0, 0, getWidth(), getHeight());
+ drawBoxShadow(0, 0, getWidth(), getHeight());
}
// ------------------------------------------------------------------------
return addItemInternal(id, label, null);
}
+ /**
+ * Convenience function to add a menu item.
+ *
+ * @param id menu item ID. Must be greater than 1024.
+ * @param label menu item label
+ * @param enabled default state for enabled
+ * @return the new menu item
+ */
+ public TMenuItem addItem(final int id, final String label,
+ final boolean enabled) {
+
+ assert (id >= 1024);
+ return addItemInternal(id, label, null, enabled);
+ }
+
/**
* Convenience function to add a custom menu item.
*
* Convenience function to add a sub-menu.
*
* @param title menu title. Title must contain a keyboard shortcut,
- * denoted by prefixing a letter with "&", e.g. "&File"
+ * denoted by prefixing a letter with "&", e.g. "&File"
* @return the new sub-menu
*/
public TSubMenu addSubMenu(final String title) {