select text of input fields when focused

- the content of input fields of relevant sheets and dialogs
  are now selected upon focus
- autofocus the Gamemaster roll modifier in the roll dialog
This commit is contained in:
Gesina Schwalbe 2021-01-24 13:11:08 +01:00
parent a8158894dd
commit 0b1c342ecf
2 changed files with 19 additions and 1 deletions

View file

@ -133,3 +133,21 @@ Hooks.once("setup", function () {
Hooks.once("ready", function () {
migration.migrate();
});
/**
* Select the text of input elements in given sheets via onfocus listener.
* The hook names are of the form "render"+sheet_superclassname and are called within
* the render() method of the foundry Application class.
* Note: The render hooks of all classes in the class hierarchy are called,
* so e.g. for a Dialog, both "renderDialog" and "renderApplication" are called
* (in this order).
*/
["renderApplication", "renderActorSheet", "renderItemSheet"].forEach((hookName: string) => {
Hooks.on(hookName, (app: Dialog, html: JQueryStatic, data: any) => {
$(html)
.find("input")
.on("focus", (ev: JQuery.FocusEvent<HTMLInputElement>) => {
ev.currentTarget.select();
});
});
});