// SPDX-FileCopyrightText: 2021 Johannes Loher // SPDX-FileCopyrightText: 2021 Gesina Schwalbe // // SPDX-License-Identifier: MIT /** * @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() { ["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. */ function selectTargetInputOnFocus(app, html) { html.find("input").on("focus", (ev) => { ev.currentTarget.select(); }); }