ds4/src/hooks/render.js

27 lines
943 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() {
2021-03-16 08:22:27 +01:00
["renderApplication", "renderActorSheet", "renderItemSheet"].forEach((hook) => {
Hooks.on(hook, selectTargetInputOnFocus);
});
}
/**
* 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) {
html.find("input").on("focus", (ev) => {
ev.currentTarget.select();
});
2021-03-16 08:22:27 +01:00
}