X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTList.java;h=e47d7512e48cd175e480298daa6488824c84335b;hb=b6faeac0d9c3e3ae3376ed28b54ec6ea6408ad7a;hp=71600485fe2b9cb1646a8df8a3c0fa5c7af5755d;hpb=56661844475522242093c8858ceb20fb15589da5;p=fanfix.git diff --git a/src/jexer/TList.java b/src/jexer/TList.java index 7160048..e47d751 100644 --- a/src/jexer/TList.java +++ b/src/jexer/TList.java @@ -81,6 +81,15 @@ public class TList extends TScrollableWidget { return null; } + /** + * Get the maximum selection index value. + * + * @return -1 if the list is empty + */ + public final int getMaxSelectedIndex() { + return strings.size() - 1; + } + /** * Set the new list of strings to display. * @@ -295,7 +304,6 @@ public class TList extends TScrollableWidget { && (mouse.getY() < getHeight() - 1)) { if (getVerticalValue() + mouse.getY() < strings.size()) { selectedString = getVerticalValue() + mouse.getY(); - dispatchEnter(); } return; } @@ -304,6 +312,26 @@ public class TList extends TScrollableWidget { super.onMouseDown(mouse); } + /** + * Handle mouse double click. + * + * @param mouse mouse double click event + */ + @Override + public void onMouseDoubleClick(final TMouseEvent mouse) { + if ((mouse.getX() < getWidth() - 1) + && (mouse.getY() < getHeight() - 1)) { + if (getVerticalValue() + mouse.getY() < strings.size()) { + selectedString = getVerticalValue() + mouse.getY(); + dispatchEnter(); + } + return; + } + + // Pass to children + super.onMouseDoubleClick(mouse); + } + /** * Handle keystrokes. *