// They selected the menu, go activate it
for (TMenu menu: menus) {
- if ((mouse.getAbsoluteX() >= menu.getX())
- && (mouse.getAbsoluteX() < menu.getX()
+ if ((mouse.getAbsoluteX() >= menu.getTitleX())
+ && (mouse.getAbsoluteX() < menu.getTitleX()
+ menu.getTitle().length() + 2)
) {
menu.setActive(true);
// See if we should switch menus
for (TMenu menu: menus) {
- if ((mouse.getAbsoluteX() >= menu.getX())
- && (mouse.getAbsoluteX() < menu.getX()
+ if ((mouse.getAbsoluteX() >= menu.getTitleX())
+ && (mouse.getAbsoluteX() < menu.getTitleX()
+ menu.getTitle().length() + 2)
) {
menu.setActive(true);
int x = 0;
for (TMenu menu: menus) {
menu.setX(x);
+ menu.setTitleX(x);
x += menu.getTitle().length() + 2;
// Don't let the menu window exceed the screen width
*/
boolean isSubMenu = false;
+ /**
+ * The X position of the menu's title.
+ */
+ private int titleX;
+
+ /**
+ * Set the menu title X position.
+ *
+ * @param titleX the position
+ */
+ public void setTitleX(final int titleX) {
+ this.titleX = titleX;
+ }
+
+ /**
+ * Get the menu title X position.
+ *
+ * @return the position
+ */
+ public int getTitleX() {
+ return titleX;
+ }
+
/**
* The shortcut and title.
*/