*EDITED*
OK, I did some debugging, and decided tor try a different method not including handling of inventory clicks in script. What I'm trying to achieve is a GUI with left double click= use, single double click = walk, right click = look. My GUI is an edited version of the original button bar, where all the buttons for changing cursor modes has been replaced by one single inventory area. When in this area I want a single left click to make the inventory item currently pointed at with the mouse to be selected.
I figured that checking weather the mouse was over a GUI or not and choosing how to interpret different clicks according to the test. My code looks like this:
function on_mouse_click(int button) {
int double_click;
if (button==LEFT) {
/*debugging code*/
string buffer;
StrFormat (buffer, "GUI %d", GetGUIAt (mouse.x, mouse.y));
SetLabelText (1, 0, buffer);
/*check if over GUI*/
if ((GetGUIAt(mouse.x,mouse.y))<0){
/* if not over GUI use on double walk on single click*/
SetMouseCursor(GetCursorMode()); // stops wait cursor appearing
double_click = WaitMouseKey(7)*IsButtonDown(LEFT);
SetDefaultCursor();
if (double_click) {
ProcessClick(mouse.x, mouse.y, MODE_USE );
}
else {
ProcessClick(mouse.x, mouse.y, MODE_WALK);
}
}
/* If NOT over gui left click = use */
else ProcessClick(mouse.x,mouse.y,MODE_USE);
}
/*Right click is always equal to look*/
if (button==RIGHT) {
ProcessClick(mouse.x, mouse.y, MODE_LOOK );
}
The looking works fine, the walking and using outside GUI works fine. But the detection of the GUI doesnt! I added a debugging code showing the reult of the test and it seems like GUI -1 (=no GUI) is always returned from GetGUIAt(mouse.x,mouse.y)
Tips, anyone?
Is this simple enough for the beginners forum, or should i try the advanced?
You'd need the on_event () function, check the parameter GUI_MDOWN. Not every mouse click passes to on_mouse_click ().
on_mouse_click also takes LEFTINV and RIGHTINV as the if (button==...) param. You might want to try if (button==LEFTINV) works any better in the inventory handling. Place it before the if (button==LEFT) sort of codes.
Thanx both of you! Radiants tip solved my problem! :D