chjj / blessed

A high-level terminal interface library for node.js.
Other
11.2k stars 528 forks source link

Can't use mouse to focus more than one textbox #406

Open sebolio opened 4 years ago

sebolio commented 4 years ago

Hi, so I have 2 textboxes and I'm trying to type text on both of them. When I click the first it works fine, but when I click on the second box, the cursor stays on the first one and typing text makes the first box to add every letter twice and the second doesn't add anything.

Code is here:

var blessed = require('blessed')
var screen = blessed.screen({
  smartCSR: true,
  title: 'La Pachala'
});
var form = blessed.form({
  parent: screen,
  width: '90%',
  left: 'center',
  keys: true,
  vi: true
});

var firstName = blessed.textbox({
  parent: form,
  name: 'firstname',
  top: 4,
  left: 5,
  height: 3,
  inputOnFocus: true,
  content: 'first',
  border: {
    type: 'line'
  },
  mouse: true
});

var xd = blessed.textbox({
  parent: form,
  name: 'xd',
  top: 8,
  left: 5,
  height: 3,
  inputOnFocus: true,
  content: 'xd',
  border: {
    type: 'line'
  },
  mouse: true
});

screen.key('q', function () {
  this.destroy();
});
screen.render();

Also, some times when pressing tab the program crashes with

TypeError: done is not a function
AngeloMateus commented 4 years ago

I'm getting this as well, I think the library just isn't being updated anymore.

sebolio commented 4 years ago

@AngeloMateus I think I just fixed in in my fork

mcbridet commented 3 years ago

@tr4g Your fork doesn't exist any more. Do you still have a snippet that fixes the problem?

pinheadmz commented 2 years ago

Anyone have a patch for this?

pinheadmz commented 2 years ago

Ok, this worked for me:

diff --git a/lib/widgets/textarea.js b/lib/widgets/textarea.js
index dc94609..9813867 100644
--- a/lib/widgets/textarea.js
+++ b/lib/widgets/textarea.js
@@ -172,9 +172,9 @@ Textarea.prototype.readInput = function(callback) {
       self.screen.restoreFocus();
     }

-    if (self.options.inputOnFocus) {
-      self.screen.rewindFocus();
-    }
+    // if (self.options.inputOnFocus) {
+    //   self.screen.rewindFocus();
+    // }

     // Ugly
     if (err === 'stop') return;