ds4/src/hooks/render.js

27 lines
927 B
JavaScript
Raw Normal View History

2021-06-26 22:02:00 +02:00
// SPDX-FileCopyrightText: 2021 Johannes Loher
// SPDX-FileCopyrightText: 2021 Gesina Schwalbe
//
// SPDX-License-Identifier: MIT
2021-03-16 08:22:27 +01:00
/**
* @remarks The render hooks of all classes in the class hierarchy are called, so e.g. for a {@link Dialog}, both the
* "renderDialog" hook and the "renderApplication" hook are called (in this order).
*/
export function registerForRenderHooks() {
2023-07-10 22:23:13 +02:00
["renderApplication", "renderActorSheet", "renderItemSheet"].forEach((hook) => {
Hooks.on(hook, selectTargetInputOnFocus);
});
2021-03-16 08:22:27 +01:00
}
/**
* Select the text of input elements in given application when focused via an on focus listener.
*
* @param {Application} app The application in which to activate the listener.
* @param {JQuery} html The {@link JQuery} representing the HTML of the application.
2021-03-16 08:22:27 +01:00
*/
function selectTargetInputOnFocus(app, html) {
2023-07-10 22:23:13 +02:00
html.find("input").on("focus", (ev) => {
ev.currentTarget.select();
});
2021-03-16 08:22:27 +01:00
}