diff options
author | Florrie <towerofnix@gmail.com> | 2019-08-25 18:08:28 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2019-08-25 18:10:43 -0300 |
commit | 878e55e7c2a203d89fb1dad83ba6d6d8751b521a (patch) | |
tree | fa938c31928806c49d855101e6dee074aa2c5856 | |
parent | acb8c05987c72ceca423acf2f5761a50f641d1f8 (diff) |
Add new property clickThrough to all elements
-rw-r--r-- | ui/DisplayElement.js | 11 |
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 } |