I need to open a menu when tapped on a button and close again when tapped for a second time.
there’s no problem with detecting the button tap, but can’t enable / disable the menu.
I have the menu as an attribute. and first I was trying enable = true / false , then read about DOM and
it turned out that UI elements are DOM elements and don’t have a relation to the entity hence enable = true won’t work.
Then tried this code:
Uimanager.attributes.add('menu', {
type:'entity',
title:'Menu'
});
Uimanager.prototype.onMenuBtnPressed = function (event)
{
var menu = this.menu;
var style = document.createElement('style');
style.appendChild(menu);
style.display = 'none';
}
but I have the common error,
"Uncaught TypeError: Failed to execute ‘appendChild’ on ‘Node’: parameter 1 is not of type ‘Node’ "
trying several different methods to be able to get the attribute and use it as a node, but not successful.
Now my main question is that, if I have a menu attached to an attribute in the script, how it can be accessed to be enable / disabled or show / hide … ?
You shouldn’t need a global variable to store the menu entity reference. The issue was that you variable that you passed as the scope for the event callback.
That said, where did this.menu come from? It’s not an attribute?
@yaustar thanks! yes after changing the last parameter to “this”
this.menu.enabled worked properly!
But can you explain more about the scope of the event.
Previously as I had set as the 3rd parameter as “this.menuButton”,
so what does it mean to have the scope of the event this.menuButton ?
I am trying to disable my html file but i cant get it to work. I have a gem in the game and when i connect with it, it disappears but the html doesn’t disappear. Can somebody help me?