X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTWidget.java;h=22766dde5aa281212c320182fbad09f76c9978f6;hb=24489803a611e99348e26cadedae1141f48c1a6c;hp=d292ec1490c938f304e142a565551d8eb6060e74;hpb=00fbfc382425d1f20a84cd8897919836cc6254ee;p=fanfix.git diff --git a/src/jexer/TWidget.java b/src/jexer/TWidget.java index d292ec1..22766dd 100644 --- a/src/jexer/TWidget.java +++ b/src/jexer/TWidget.java @@ -302,6 +302,25 @@ public abstract class TWidget implements Comparable { * @return if true, this widget has a visible cursor */ public final boolean isCursorVisible() { + // If cursor is out of my bounds, it is not visible. + if ((cursorX >= width) + || (cursorX < 0) + || (cursorY >= height) + || (cursorY < 0) + ) { + return false; + } + + // If cursor is out of my window's bounds, it is not visible. + if ((getCursorAbsoluteX() >= window.getAbsoluteX() + + window.getWidth() - 1) + || (getCursorAbsoluteX() < 0) + || (getCursorAbsoluteY() >= window.getAbsoluteY() + + window.getHeight() - 1) + || (getCursorAbsoluteY() < 0) + ) { + return false; + } return cursorVisible; }