According to the Accelerator documentation, I should be able to send key commands like Ctrl+A and Return.
Using the following, I can send key commands one at a time:
//ch = current key command, like 'a' or 'Backspace'
webView.sendInputEvent({
type: 'keyDown',
keyCode: ch
});
webView.sendInputEvent({
type: 'char',
keyCode: ch
});
webView.sendInputEvent({
type: 'keyUp',
keyCode: ch
});
This works fine for ordinary letter keypresses, and even Backspace, but the above won't honor modifier combinations like Ctrl+A, or even some single modifiers like Return or Enter. If I enter text on a textarea and then send Return, I would expect a newline to be added to the textarea.
From the Electron documentation (emphasis mine):
keyCode String (required) - The character that will be sent as the keyboard event. Should only use the valid key codes in Accelerator.
It would seem by that documentation, the newline should get added.
Is that expectation correct? If so, what am I doing wrong?
Related
I'm doing a POC with playwright with {expect} from '#playwright/test'.
I'm a bit confused how to create the regexp, I expect to validate this string which is correct as per the regex validator.
expect('abc123').toMatch('abc(\d+)')
first the '\' is marked as Unnecessary escape character
tried '\\' marks error
removed '\' marks error
How about toMatchText:
import { expect } from '#playwright/test';
await expect('abc123').toMatchText(/abc\d+/);
I don't see toMatch in the docs, so I used toMatchText(). I also think that capturing group in the regex () is not necessary in this example, so \d+ should be enough.
import { expect } from '#playwright/test';
let pattern = new RegExp('abc(\d+)');
const text = await page.locator('.label').textContent();
expect(text).toEqual(expect.stringMatching(pattern));
On this example you can receive a Regular Expression parameter as string and converted to a RegExp object, hence backlashes are not explicitly necessary.
Then compare with a text with expect.stringMatching as shown in the last row
I want the Information Message to show two lines of text.
Can this be done using one message class statement. Ex.
MESSAGE i001(z56_myclass) WITH lv_cust_id.
I tried putting the string of the short text with characters \n # \r \\n etc. but nothing worked. I don't know how to use long text editor for this particular requirement. Any help would be great.
You can't control the message carriage return in MESSAGE statement.
You can try instead with the following information popup
call function 'POPUP_TO_INFORM'
exporting
titel = 'Information'
txt1 = 'Registration successful'
txt2 = 'Customer Id is 0000001234'.
You have 4 text rows at your disposal (from txt1 to txt4).
stdin.readByteSync has recently been added to Dart.
Using stdin.readByteSync for data entry, I am attempting to allow a default value and if an entry is made by the operator, to clear the default value. If no entry is made and just enter is pressed, then the default is used.
What appears to be happening however is that no terminal output is sent to the terminal until a newline character is entered. Therefore when I do a print() or a stdout.write(), it is delayed until newline is entered.
Therefore, when operator enters first character to override default, the default is not cleared. IE. The default is "abc", data entered is "xx", however "xxc" is showing on screen after entry of "xx". The "problem" appears to be that no "writes" to the terminal are sent until newline is entered.
While I can find an alternative way of doing this, I would like to know if this is the way readByteSync should or must work. If so, I’ll find an alternative way of doing what I want.
// Example program //
import 'dart:io';
void main () {
int iInput;
List<int> lCharCodes = [];
print(""); print("");
String sDefault = "abc";
stdout.write ("Enter data : $sDefault\b\b\b");
while (iInput != 10) { // wait for newline
iInput = stdin.readByteSync();
if (iInput == 8 && lCharCodes.length > 0) { // bs
lCharCodes.removeLast();
} else if (iInput > 31) { // ascii printable char
lCharCodes.add(iInput);
if (lCharCodes.length == 1)
stdout.write (" \b\b\b\b chars cleared"); // clear line
print ("\nlCharCodes length = ${lCharCodes.length}");
}
}
print ("\nData entered = ${new String.fromCharCodes(lCharCodes).trim()}");
}
Results on Command screen are :
c:\Users\Brian\dart-dev1\test\bin>dart testsync001.dart
Enter data : xxc
chars cleared
lCharCodes length = 1
lCharCodes length = 2
Data entered = xx
c:\Users\Brian\dart-dev1\test\bin>
I recently added stdin.readByteSync and readLineSync, to easier create small scrips reading the stdin. However, two things are still missing, for this to be feature-complete.
1) Line mode vs Raw mode. This is basically what you are asking for, a way to get a char as soon as it's printed.
2) Echo on/off. This mode is useful for e.g. typing in passwords, so you can disable the default echo of the characters.
I hope to be able to implement and land these features rather soon.
You can star this bug to track the development of it!
This is common behavior for consoles. Try to flush the output with stdout.flush().
Edit: my mistake. I looked at a very old revision (dartlang-test). The current API does not provide any means to flush stdout. Feel free to file a bug.
I'm currently teaching myself the Dart language, and my first app doesn't seem to be working right. Here's the code that's causing trouble:
usrLoc = int.parse(query("#txtLoc").text);
When I try to run the app, it opens fine, but when I click the button that triggers this (and three other similar parses), the debugger stops and tells me "Source not found" for int._native_parse(), int._parse(), and int.parse().
Any help would be greatly appreciated.
The text property for the specified element #txtLoc returns an empty string.
The parse method requires that:
The source must be a non-empty sequence of base- radix digits, optionally prefixed with a minus or plus sign ('-' or '+').
You can specify an onError named argument in your call to parse, which takes a callback that handles the invalid input. E.g., if you want the parse call to return the value 42 for all invalid input, you can do this:
usrLoc = int.parse(query("#txtLoc").text, onError: (val) => 42);
If you really expect the element to have some text, you can store the result of query("#txtLoc").text into a separate variable and verify the value. It would also be interesting to check what the real element type is or which tag is marked with id #txtLoc.
If you want to get the content of an input element, you should use the value property instead of text:
query("#txtLoc").value
We recently purchased a highcharts license and have integrated it with our Grails application.
We're having some difficulty in that we're unable to specify a tool tip formatter in the JSON object that we're returning because it appears that the HighCharts JSON object doesn't conform to the JSON standards.
Specifically, it appears that JSON is not technically allowed to have JavaScript functions as an object property. From the www.json.org website:
A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string.
So, when we output our formatting string, it gets wrapped in double quotes, like this:
"formatter": "this.x + ': ' + this.y",
Can we get an enhancement where we specify a tooltip (or tooltip-fn) property as a string, which is the name of a javascript function? For example:
"formatter": "myTooltipFn"
which calls a javascript function like:
myTooltipFn(chart) {
return chart.x
}
I've just fixed this after hours of labour. My solution was to add the formatter to the data AFTER the data is sent in JSON format to the browser.
So basically, in the js file that has this line:
$(blah).highcharts(data);
write BEFORE this line:
Data.tooltip.formatter = function() {
//write function here
}