hide context menu if empty
This commit is contained in:
parent
2b69d338c3
commit
a4477a8c5e
1 changed files with 7 additions and 1 deletions
|
@ -30,8 +30,12 @@ class Contextmenu<x,y>{
|
||||||
makemenu(x:number,y:number,addinfo:any,other:y){
|
makemenu(x:number,y:number,addinfo:any,other:y){
|
||||||
const div=document.createElement("div");
|
const div=document.createElement("div");
|
||||||
div.classList.add("contextmenu","flexttb");
|
div.classList.add("contextmenu","flexttb");
|
||||||
|
|
||||||
|
let visibleButtons=0;
|
||||||
for(const thing of this.buttons){
|
for(const thing of this.buttons){
|
||||||
if(!thing[3].bind(addinfo)(other)){continue;}
|
if(!thing[3].bind(addinfo)(other))continue;
|
||||||
|
visibleButtons++;
|
||||||
|
|
||||||
const intext=document.createElement("button")
|
const intext=document.createElement("button")
|
||||||
intext.disabled=!thing[4].bind(addinfo)(other);
|
intext.disabled=!thing[4].bind(addinfo)(other);
|
||||||
intext.classList.add("contextbutton")
|
intext.classList.add("contextbutton")
|
||||||
|
@ -43,6 +47,8 @@ class Contextmenu<x,y>{
|
||||||
|
|
||||||
div.appendChild(intext);
|
div.appendChild(intext);
|
||||||
}
|
}
|
||||||
|
if (visibleButtons == 0) return;
|
||||||
|
|
||||||
if(Contextmenu.currentmenu!=""){
|
if(Contextmenu.currentmenu!=""){
|
||||||
Contextmenu.currentmenu.remove();
|
Contextmenu.currentmenu.remove();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue