« get me outta code hell

tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ui/DisplayElement.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/ui/DisplayElement.js b/ui/DisplayElement.js
index 9498487..b7e07b9 100644
--- a/ui/DisplayElement.js
+++ b/ui/DisplayElement.js
@@ -26,6 +26,11 @@ module.exports = class DisplayElement extends EventEmitter {
 
     this.hPadding = 0
     this.vPadding = 0
+
+    // Note! This only applies to the parent, not the children. Useful for
+    // when you want an element to cover the whole screen but allow mouse
+    // events to pass through.
+    this.clickThrough = false
   }
 
   drawTo(writable) {
@@ -196,13 +201,17 @@ module.exports = class DisplayElement extends EventEmitter {
   }
 
   getElementAt(x, y) {
+    // Gets the topmost element at the provided absolute coordinate.
+    // Note that elements which are not visible or have the clickThrough
+    // property set to true are not considered.
+
     const children = this.children.slice()
 
     // Start searching the last- (top-) rendered children first.
     children.reverse()
 
     for (const el of children) {
-      if (!el.visible) {
+      if (!el.visible || el.clickThrough) {
         continue
       }