To make this easier for you to use, I will make it as a script, which could be easily used. I will create it such that it will be called: link(x,y,"name"
;Very easy. First of all, in the script I will start to define these values...
xv = argument0;
yv = argument1;
nv = argument2;
And then continue with drawing the text:
draw_text(xv,yv,nv);
Now that all the visual stuff is handled (except if you want to add something stylish, like making the links blue; you could do that as well) we'll controll whether or not the mouse is in the area:
if (mouse_x<xv+string_width(nv)) && (mouse_x>xv) &&
(mouse_y<yv+string_height(nv)) && (mouse_y>yv) {
clickable = true;
}
else {
clickable = false;
}
So now we have a script for the draw event:
xv = argument0;
yv = argument1;
nv = argument2;
draw_text(xv,yv,nv);
if (mouse_x<xv+string_width(nv)) && (mouse_x>xv) &&
(mouse_y<yv+string_height(nv)) && (mouse_y>yv) {
clickable = true;
selected = nv;
}
else {
clickable = false;
}
In global left release event all you need to put is:
if (clickable == true) {
show_message("You've just clicked "+string(selected));
}
You can do anything inside the brackets, for an example, if nv is a url or file path, you could do like this:
if (clickable == true) {
execute_program(nv,"",true)
}
Ask any questions that you have on this article by commenting.
Comments
Loading comments...