X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTWidget.java;h=22766dde5aa281212c320182fbad09f76c9978f6;hb=1b1206070bb94d706c14400b8332a81646b77a25;hp=08c0a45ca9c68c28c8345b14faa5f1344d852daf;hpb=12b55d76e3473407bf37fca3667860240cb8f3be;p=fanfix.git diff --git a/src/jexer/TWidget.java b/src/jexer/TWidget.java index 08c0a45..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; } @@ -550,6 +569,13 @@ public abstract class TWidget implements Comparable { } } + /** + * Repaint the screen on the next update. + */ + public void doRepaint() { + window.getApplication().doRepaint(); + } + // ------------------------------------------------------------------------ // Constructors ----------------------------------------------------------- // ------------------------------------------------------------------------ @@ -990,7 +1016,8 @@ public abstract class TWidget implements Comparable { /** * Method that subclasses can override to do processing when the UI is - * idle. + * idle. Note that repainting is NOT assumed. To get a refresh after + * onIdle, call doRepaint(). */ public void onIdle() { // Default: do nothing, pass to children instead