The standard dropdown menu for the header menu is a bit basic, so I did some research and saw that I could make my own (a mega menu). I did, and I used the code below to make sure when the user hovered over a button, the dropdown menu would appear. This worked. However, when I hovered my mouse outside the dropdown menu (and the button) it didn’t disappear. How can I make it disappear? Any suggestions are welcome
Code I used:
export function button1_mouseIn(event) {
$w('#dropdownmenu').show();
}
export function button1_mouseOut(event) {
$w('#dropdownmenu').hide();
}
export function dropdownmenu_mouseOut(event) {
$w('#dropdownmenu').hide();
$w('#button1').enable()
}
Your code seems correct you’re just missing another mouseIn event for the dropdownMenu to make sure it stays showing the menu when hovered over it after leaving the button.
You can do something like:
export function button1_mouseIn(event) {
$w('#dropdownmenu').show();
}
export function button1_mouseOut(event) {
$w('#dropdownmenu').hide();
}
export function dropdownmenu_mouseIn(event) {
$w('#dropdownmenu').show();
}
export function dropdownmenu_mouseOut(event) {
$w('#dropdownmenu').hide();
}
Hey! This might help and it might not, but when working with mouseIn / onClick events, I ALWAYS forget to add my Event Handlers in the Properties panel.
I add the code but forget the necessary handlers (or the event handler has a different name than in my code), so maybe double-check that everything is there and matches up!
@alexrego2000 Hey! I’m not exactly sure how you have your boxes/buttons setup but I ran into a similar problem when building mine. I had to set it up with the button (green line) overlapping the box (red line), so that when the cursor comes off the button it goes directly onto the box. Otherwise, when the cursor comes off the button it triggers the mouseOut event, which collapses the box and makes it unable to fulfill the mouseIn event. If that makes sense.
Hey guys ,
I have trying to create mega menu on my site for last about a week … tried my best efforts but failed maybe because I don’t have any experience of coding
But I am not going to give it up ! Can anyone of you just guide how to do this ? Shall be grateful please !