Comments (1)
I experienced this while trying to make my own input box. I figured out that key.sequence was the correct value to add rather than key.name (which is undefined for special characters)
These lines of code in particular need key.name to be changed to key.sequence
src/components/widgets/InputPopup.ts
tmp += key.name
this.value = tmp
Working example:
Code:
Show code
inputBox.on("keypress", (key: KeyListenerArgs) => {
// let user type in input without typing here
if (!inputBox.focused) return;
__d_lastKey = JSON.stringify(key);
switch (key.name) {
case "/":
break;
case "backspace":
if (input.length === 0) isCommand = false;
input = input.slice(0, -1);
cursorPos = Math.max(0, cursorPos - 1);
break;
case "delete": {
if (cursorPos === 0) return;
const leftPart = input.slice(0, cursorPos - 1);
const rightPart = input.slice(cursorPos);
input = leftPart + rightPart;
break;
}
case "space":
input += " ";
cursorPos++;
break;
case "tab":
// no-op for now
break;
case "return":
case "enter":
// handled in other listener
break;
case "home":
cursorPos = 0;
break;
case "end":
cursorPos = input.length;
break;
case "left":
cursorPos = Math.max(0, cursorPos - 1);
break;
case "right":
cursorPos = Math.min(input.length, cursorPos + 1);
break;
default:
if (key.sequence.length !== 1) break;
if (key.sequence === "/" && !isCommand && input.length === 0) {
isCommand = true;
break;
}
const leftPart = input.slice(0, cursorPos);
const rightPart = input.slice(cursorPos);
input = leftPart + key.sequence + rightPart;
cursorPos++;
break;
}
drawMessage();
});
from console-gui-tools.
Related Issues (20)
- Add the possibility to include a Control Widget inside a PageBuilder instance
- Add mouse feature to layout
- Add tab index to Controls to focus them with the keyboard and use keyboard only for them HOT 1
- Make a draggable progressbar to use like "analog" selector HOT 1
- When "enableMouse" is false, any key press cause a crash
- Add "increment" parameter to ProgressBar to define how much increase the value at every input change HOT 6
- Adding ASCII ART Text builder (For inPageBuilder) HOT 5
- Add keyboard key to push button
- [Feature]: Change all class constructors parameters with one single object with optional props
- [Bug]: OptionPopup - selected prop = "" is considered undefined HOT 3
- [Feature]: Popups Offset HOT 3
- [Feature]: addColumn (instead of double or quad) HOT 12
- [Bug]: LayoutOptions.changeFocusKey marked as required
- [Feature] Integrate Mouse Capture for Windows (Using C++ binding with Windows.h)
- [Bug]: InputPopup can handle strings HOT 1
- [Support]: InputPopup string limit
- [Bug]: Button click does not work HOT 1
- [Bug]: Error using Libary in ESM Project (TS 7016) HOT 8
- [Feature]: Added Support so the Process needs not be ended with process.exit() HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from console-gui-tools.