-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Toevoegen context menu in het situatieschema voor snellere aanpassi…
…ng van symbool-eigenschappen. - Adreslocatie roteert mee indien via het contextmenu een rotatie wordt uitgevoerd. - In het print-menu twee HTML veldjes een formeel id gegeven (warning google Chrome) - Enter toets op een symbool opent nu ook de symbooleigenschappen - Ctrl-pijlen doet nu een symbool roteren in het situatieschema
- Loading branch information
Showing
9 changed files
with
559 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
var CONF_builddate="20250202-152459" | ||
var CONF_builddate="20250209-140637" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
class ContextMenu { | ||
private menuItems: { label: string, shortcut?: string, callback: () => void }[] = []; | ||
private menuElement: HTMLElement | null = null; | ||
|
||
/** | ||
* Constructor voor het initialiseren van het contextmenu-element. | ||
* @param div - Het HTML-element waaraan het contextmenu wordt toegevoegd. | ||
*/ | ||
constructor(div: HTMLElement = document.body) { | ||
this.menuElement = document.createElement('div'); | ||
this.menuElement.className = 'context-menu'; | ||
div.appendChild(this.menuElement); | ||
} | ||
|
||
/** | ||
* Wis alle menu-items. | ||
*/ | ||
clearMenu(): void { | ||
this.menuItems = []; | ||
if (this.menuElement) { | ||
this.menuElement.innerHTML = ''; | ||
} | ||
} | ||
|
||
/** | ||
* Voeg een menu-item toe met een optionele sneltoets. | ||
* @param label - De tekstlabel van het menu-item. | ||
* @param callback - De functie die wordt aangeroepen bij het klikken op het menu-item. | ||
* @param shortcut - De optionele sneltoets voor het menu-item. | ||
*/ | ||
addMenuItem(label: string, callback: () => void, shortcut?: string): void { | ||
this.menuItems.push({ label, shortcut, callback }); | ||
} | ||
|
||
/** | ||
* Voeg een scheidingslijn toe aan het menu. | ||
*/ | ||
addLine(): void { | ||
this.menuItems.push({ label: 'separator', callback: () => {} }); | ||
} | ||
|
||
/** | ||
* Render de menu-items. | ||
*/ | ||
private renderMenu(): void { | ||
if (this.menuElement) { | ||
this.menuElement.innerHTML = ''; | ||
this.menuItems.forEach((item, index) => { | ||
if (item.label === 'separator') { | ||
const separator = document.createElement('hr'); | ||
separator.className = 'context-menu-separator'; | ||
this.menuElement.appendChild(separator); | ||
} else { | ||
const menuItem = document.createElement('div'); | ||
menuItem.className = 'context-menu-item'; | ||
|
||
const labelElement = document.createElement('span'); | ||
labelElement.textContent = item.label; | ||
|
||
const shortcutElement = document.createElement('span'); | ||
shortcutElement.textContent = item.shortcut || ''; | ||
shortcutElement.className = 'context-menu-shortcut'; | ||
|
||
menuItem.appendChild(labelElement); | ||
menuItem.appendChild(shortcutElement); | ||
|
||
menuItem.addEventListener('click', () => { | ||
item.callback(); | ||
this.hide(); | ||
}); | ||
|
||
this.menuElement.appendChild(menuItem); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
/** | ||
* Toon het contextmenu op de locatie van de muisklik. | ||
* @param event - Het muisgebeurtenisobject. | ||
*/ | ||
show(event: MouseEvent): void { | ||
if (this.menuElement) { | ||
this.renderMenu(); | ||
this.menuElement.style.display = 'block'; | ||
const { clientX, clientY } = event; | ||
const { innerWidth, innerHeight } = window; | ||
const { offsetWidth, offsetHeight } = this.menuElement; | ||
|
||
let left = clientX; | ||
let top = clientY; | ||
|
||
if (left + offsetWidth > innerWidth) { | ||
left = innerWidth - offsetWidth; | ||
} | ||
if (top + offsetHeight > innerHeight) { | ||
top = innerHeight - offsetHeight; | ||
} | ||
|
||
this.menuElement.style.left = `${left}px`; | ||
this.menuElement.style.top = `${top}px`; | ||
} | ||
} | ||
|
||
/** | ||
* Verberg het contextmenu. | ||
*/ | ||
hide(): void { | ||
if (this.menuElement) { | ||
this.menuElement.style.display = 'none'; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.