ElementsnStuff
Member
I've been trying to code a scrolling interactive menu and been running into some trouble. I use what I think is a pretty simple argument to check if the mouse is touching a selection box when pressed - if its x is between the bounds of the box, and its y is between the bounds of the box cut into the number of entries on the screen (in this case, 10 rectangles each with textboxheight/10 as height). This changes the selected entry's font from the regular color to a bright yellow color. However, I've been running into some odd issues with the left mouse button press.
Pressing the left mouse button directly on the desired entry does nothing. To troubleshoot this, I simplified the problem by making the first entry always selected if the mouse button is pressed within the x boundaries of the textbox. However, this still does nothing... until another key is pressed (doesn't matter what). The moment any other key is pressed, the first entry will light up yellow exactly as planned - but it still completely ignores the mouse.
I've attached what I believe is all the relevant code for the object (there are other events for moving the view around and scrolling the textbox, but those don't seem to affect anything). Views are turned on and the object is always offset from the room's view by a fixed amount. Can anyone spot why this is happening?
Create:
Step:
Draw:
Pressing the left mouse button directly on the desired entry does nothing. To troubleshoot this, I simplified the problem by making the first entry always selected if the mouse button is pressed within the x boundaries of the textbox. However, this still does nothing... until another key is pressed (doesn't matter what). The moment any other key is pressed, the first entry will light up yellow exactly as planned - but it still completely ignores the mouse.
I've attached what I believe is all the relevant code for the object (there are other events for moving the view around and scrolling the textbox, but those don't seem to affect anything). Views are turned on and the object is always offset from the room's view by a fixed amount. Can anyone spot why this is happening?
Create:
GML:
///dropdown selection bar
f=1;//current topmost position, set at 0 to start with
global.selected=0;
global.basicfont=font_add_sprite_ext(spr_font,"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz?!,.-'♂♀01234",true,1);
global.selectedfont=font_add_sprite_ext(spr_font_selected,"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz?!,.-'♂♀01234",true,1);
GML:
x=view_xview+200;
y=view_yview+15;
global.trackx=x;
global.tracky=y;
global.trackmx=mouse_x;
global.trackmy=mouse_y;
if keyboard_check_pressed(mb_left){
if ((x<mouse_x) and (mouse_x<(x+100))){
global.selected=f;
}
}
GML:
draw_rectangle_color(x-2,y-2,x+100,y+115,c_white,c_white,c_white,c_white,false);
draw_rectangle_color(x-2,y-2,x+100,y+115,c_black,c_black,c_black,c_black,true);
draw_rectangle_color(x-2,y-2,x+100,y+10,c_white,c_white,c_white,c_white,false);
draw_rectangle_color(x-2,y-2,x+100,y+10,c_black,c_black,c_black,c_black,true);
for(i=0;i<10;i++){
if (f+i)<494{
if (f+i)!=global.selected{
draw_set_font(global.basicfont);
}
else if (f+i)==global.selected{
draw_set_font(global.selectedfont);
}
draw_text(x,y+12+(10*i),L[f+i]);
}
}