Added delete key shortcut to select maps and tokens modal
This commit is contained in:
parent
8d85f6e347
commit
fa659bc80a
@ -46,13 +46,9 @@ function MapTiles({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let hasSelectedDefaultMap = false;
|
let hasSelectedDefaultMap = selectedMaps.some(
|
||||||
for (let map of selectedMaps) {
|
(map) => map.type === "default"
|
||||||
if (map.type === "default") {
|
);
|
||||||
hasSelectedDefaultMap = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function mapToTile(map) {
|
function mapToTile(map) {
|
||||||
const isSelected = selectedMaps.includes(map);
|
const isSelected = selectedMaps.includes(map);
|
||||||
|
@ -33,16 +33,10 @@ function TokenTiles({
|
|||||||
const { databaseStatus } = useContext(DatabaseContext);
|
const { databaseStatus } = useContext(DatabaseContext);
|
||||||
const isSmallScreen = useMedia({ query: "(max-width: 500px)" });
|
const isSmallScreen = useMedia({ query: "(max-width: 500px)" });
|
||||||
|
|
||||||
let hasSelectedDefaultToken = false;
|
let hasSelectedDefaultToken = selectedTokens.some(
|
||||||
let allTokensVisible = true;
|
(token) => token.type === "default"
|
||||||
for (let token of selectedTokens) {
|
);
|
||||||
if (token.type === "default") {
|
let allTokensVisible = selectedTokens.every((token) => !token.hideInSidebar);
|
||||||
hasSelectedDefaultToken = true;
|
|
||||||
}
|
|
||||||
if (token.hideInSidebar) {
|
|
||||||
allTokensVisible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function tokenToTile(token) {
|
function tokenToTile(token) {
|
||||||
const isSelected = selectedTokens.includes(token);
|
const isSelected = selectedTokens.includes(token);
|
||||||
|
@ -298,6 +298,15 @@ function SelectMapModal({
|
|||||||
if (key === "Control" || key === "Meta") {
|
if (key === "Control" || key === "Meta") {
|
||||||
setSelectMode("multiple");
|
setSelectMode("multiple");
|
||||||
}
|
}
|
||||||
|
if (key === "Backspace" || key === "Delete") {
|
||||||
|
// Selected maps and none are default
|
||||||
|
if (
|
||||||
|
selectedMapIds.length > 0 &&
|
||||||
|
!selectedMaps.some((map) => map.type === "default")
|
||||||
|
) {
|
||||||
|
setIsMapsRemoveModalOpen(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleKeyUp({ key }) {
|
function handleKeyUp({ key }) {
|
||||||
|
@ -170,6 +170,15 @@ function SelectTokensModal({ isOpen, onRequestClose }) {
|
|||||||
if (key === "Control" || key === "Meta") {
|
if (key === "Control" || key === "Meta") {
|
||||||
setSelectMode("multiple");
|
setSelectMode("multiple");
|
||||||
}
|
}
|
||||||
|
if (key === "Backspace" || key === "Delete") {
|
||||||
|
// Selected tokens and none are default
|
||||||
|
if (
|
||||||
|
selectedTokenIds.length > 0 &&
|
||||||
|
!selectedTokens.some((token) => token.type === "default")
|
||||||
|
) {
|
||||||
|
setIsTokensRemoveModalOpen(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleKeyUp({ key }) {
|
function handleKeyUp({ key }) {
|
||||||
|
Loading…
Reference in New Issue
Block a user