Select contents on start edit of input field [message #1858126] |
Thu, 16 March 2023 10:06  |
Eclipse User |
|
|
|
Hi,
is it possible to automatically select the contents of an input field (String, Long, BigDecimal, ...) in Scout Classic when the users clicks in the field. The intention is to replace the contents by starting to type or to add, after using for example cursor keys or clicking another time like it is done e.g. in the address bar of chrome and edge?
I know that there is the setting:
@Override
protected String getConfiguredClearable() {
return CLEARABLE_ALWAYS;
}
and that would be the alternative if there is no such setting and it can't be added easily.
Thanks
Nils
|
|
|
|
Re: Select contents on start edit of input field [message #1858289 is a reply to message #1858219] |
Mon, 27 March 2023 09:57  |
Eclipse User |
|
|
|
Hi Claudio,
for now I want to use it on all fields, so I will use the simple way and just replace the StringField. You are right, at least on larger fields the user should have the possiblilty to select text and adding the listener to 'mouseup' is working great.
import {StringField} from '@eclipse-scout/core';
export class MyStringField extends StringField {
protected override _render() {
super._render();
this.$field.on('mouseup', event => {
if (event.target.selectionEnd - event.target.selectionStart == 0) {
event.target.select();
}
});
}
}
Thank you.
Nils
|
|
|
Powered by
FUDForum. Page generated in 0.05458 seconds