Skip to content

Commit caa68be

Browse files
committed
combo
1 parent b0f4787 commit caa68be

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

js/context_menu.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { app } from "../../scripts/app.js"
2+
import { Timings } from "./constants.js"
23

34
var context_menu
5+
var closable = false
46

57
function autoclose(e) {
68
if (context_menu?.root?.contains(e.target)) return
@@ -9,17 +11,30 @@ function autoclose(e) {
911

1012
export function close_context_menu() {
1113
context_menu?.close()
14+
if (closable) {
15+
Array.from(document.getElementsByClassName('litecontextmenu')).forEach((e)=>e.remove())
16+
}
17+
closable = false
1218
context_menu = null
1319
}
1420

15-
function _open_context_menu(e, title, values) {
21+
export function register_closable() {
22+
closable = true
23+
}
24+
25+
function _open_context_menu(e, title, values, opts) {
1626
close_context_menu()
27+
1728
const options = {
1829
"title":title,
1930
"event":e,
2031
}
32+
if (opts) Object.assign(options, opts)
2133
context_menu = LiteGraph.ContextMenu(values, options, app.canvas.getCanvasWindow())
2234
}
23-
export function open_context_menu(e, title, values) { setTimeout(_open_context_menu, 10, e, title, values) }
35+
export function open_context_menu(e, title, values, opts, node) {
36+
if (node) app.canvas.current_node = node
37+
setTimeout(_open_context_menu, Timings.GENERIC_SHORT_DELAY, e, title, values, opts)
38+
}
2439

2540
window.addEventListener('click',autoclose)

0 commit comments

Comments
 (0)