« get me outta code hell

Mouse support - tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
path: root/ui/form/Button.js
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2018-12-08 02:37:15 -0400
committerFlorrie <towerofnix@gmail.com>2018-12-08 02:37:15 -0400
commit1f434c1ef11fa55bab1718ea4e3ca8d115c0dfb1 (patch)
tree341321a95d376faf720dda8d4e0ca4b69880f3e6 /ui/form/Button.js
parent013835d81e5e56f59faf17e215a73f9e8dc4310b (diff)
Mouse support
Not exactly the most elegant implementation, but it definitely works and
isn't really difficult to code around!
Diffstat (limited to 'ui/form/Button.js')
-rw-r--r--ui/form/Button.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/ui/form/Button.js b/ui/form/Button.js
index 3a35912..46329a6 100644
--- a/ui/form/Button.js
+++ b/ui/form/Button.js
@@ -38,4 +38,14 @@ module.exports = class Button extends FocusElement {
       this.emit('pressed')
     }
   }
+
+  clicked(button) {
+    if (button === 'left') {
+      if (this.isSelected) {
+        this.emit('pressed')
+      } else {
+        this.root.select(this)
+      }
+    }
+  }
 }