From 878e55e7c2a203d89fb1dad83ba6d6d8751b521a Mon Sep 17 00:00:00 2001 From: Florrie Date: Sun, 25 Aug 2019 18:08:28 -0300 Subject: Add new property clickThrough to all elements --- ui/DisplayElement.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'ui/DisplayElement.js') 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 } -- cgit 1.3.0-6-gf8a5