flyinian
Member
I am trying to create a contextual menu and so, far so good besides the fact that I can't figure out how to keep the sub menu open(active?).
Menu 1 > sub menu 1 > item 1 , item 2, and so forth. The sub menu is the list of item 1, item 2 and so forth.
Mouse Hover on Menu 1 > Should open the sub menu > with its menu options that are clickable to activate their code.
When I hover over Menu 1 it opens the sub menu as it should and I am able to drag my cursor over to it to keep it open but all of the items within the sub menu besides the first item which is where my cursor is currently located closes/disappears/etc.
I am following a video tutorial for this and here is that video. In the video the first menu will be destroyed for that the second menu can be created and I have stopped that from happening and want all menu to still show while I am still interacting with it until the mouse leaves the buttons.
Below is the step event that creates the menu.
Here is this code. This code belongs in the object that spawns the buttons.
Let me know if you need any clarification and I hope the code I provided will suffice. I believe I am just missing a simple line of code in one of these events.
Thank you.
Menu 1 > sub menu 1 > item 1 , item 2, and so forth. The sub menu is the list of item 1, item 2 and so forth.
Mouse Hover on Menu 1 > Should open the sub menu > with its menu options that are clickable to activate their code.
When I hover over Menu 1 it opens the sub menu as it should and I am able to drag my cursor over to it to keep it open but all of the items within the sub menu besides the first item which is where my cursor is currently located closes/disappears/etc.
I am following a video tutorial for this and here is that video. In the video the first menu will be destroyed for that the second menu can be created and I have stopped that from happening and want all menu to still show while I am still interacting with it until the mouse leaves the buttons.
Below is the step event that creates the menu.
Code:
//step event
if (point_in_rectangle(mouse_x, mouse_y, x - Width, y - Height, x + Width, y + Height))
{
Hover = 1; //set hover to 1
HoverColor = c_yellow;
if (mouse_check_button(mb_left))
{
Hover = 2;
HoverColor = c_red;
}
}
else
{
Hover = 0;
HoverColor = c_white;
}
if (Hover == 1)
{
if(mouse_check_button_released(mb_left))
{
switch(BUTTON_TYPE)
{
case 1: //menu 1
with(obj_buttonspawner)
{
event_user(0);
}
break;
case 2: //menu 2
with(obj_buttonspawner)
{
event_user(1);
}
break;
case 3: //menu 3
with(obj_buttonspawner)
{
event_user(2);
}
break;
case 4: //menu 4
with(obj_buttonspawner)
{
event_user(3);
}
break;
default:
break;
}}}
Code:
//User-Event(0)
//The creates the popup menus when mouse hover
with(obj_button)
{
There was an "instance_destroy()" in here and I removed it so it would't destroy my menu 1 with mouse click/hover.
}
var Button_1 = instance_create_depth(view_xport[0] + 249, view_yport[0] + 23, 1,obj_subbutton);
Button_1.BUTTON_TYPE = 1;
Button_1.HoverValue = 1;
var Button_2 = instance_create_depth(view_xport[0] + 249, view_yport[0] + 83, -5000,obj_subbutton);
Button_2.BUTTON_TYPE = 2;
Button_2.HoverValue = 2;
var Button_3 = instance_create_depth(view_xport[0] + 249, view_yport[0] + 143, -5000,obj_subbutton);
Button_3.BUTTON_TYPE = 3;
Button_3.HoverValue = 3;
var Button_4 = instance_create_depth(view_xport[0] + 249, view_yport[0] + 206, -5000,obj_subbutton);
Button_4.BUTTON_TYPE = 4;
Button_4.HoverValue = 4;
Let me know if you need any clarification and I hope the code I provided will suffice. I believe I am just missing a simple line of code in one of these events.
Thank you.