I have this inventory where there are no buttons. I want the user to right-click to select the cursor mode, Sierra style. I can get it to right click on the GUI itself and on top of a inventory item, but on top of the inventory box nothing happens! Can anyone offer a solution to this? (2.7 solution is fine).
While we're at it, when you handle custom inventory clicks in script, how do you set the cursor mode to active inventory? I have:
else if (button == eMouseLeftInv) {
if(mouse.Mode == eModeInteract) player.ActiveInventory = inventory[game.inv_activated];
else inventory[game.inv_activated].RunInteraction(mouse.Mode);
}
... on my on_mouse_click, but that's not doing the trick.
Hmmm, I had that problem once... now what did CJ tell me to try?
...hmm, well, whatever it is it's a workaround. I think it might be using the GUI_MDOWN on_event function to capture the clicking. That was before 2.7, but if the new way doesn't cut it, give this a try. Put the on_event function before the mouse_click function and if GUI_MDOWN and {assorted checks to see if it's the right place} then on_mouse_click(eMouseButtonRight). Or something of the sort, of course, I'm going by memory here.
What I think Rui means is:
function on_event(EventType event, int data) {
if (event == eEventGUIMouseDown) {
if (data == gInventory.ID) {
if (mouse.IsButtonDown(eMouseRight)) Mouse.SelectNextMode();
}
}
}
(adapted from 2.62, but tested in 2.7, so it SHOULD work.)
Hey, that worked! Now, why is it it that I can't click on inventory items yet?
If you want the default right mouse click action to be possible from everywhere, you could do:
function on_event(EventType event, int data) {
//...
if (event == eEventGUIMouseDown) {
if (mouse.IsButtonDown(eMouseRight)) on_mouse_click(eMouseRight);
}
//...
}
The on_event function has to be located after the on_mouse_click function for this to work.
Then, in on_mouse_click, I have something like this:
//...
if (button == eMouseRight) {
if (mouse.Mode != eModePointer) mouse.SelectNextMode();
}
//...
This way, to disable the right click, I just have to set the mouse mode to Pointer.
well, it works just fine, but my question is why is left clicking not working when I left click on an inventory item?
Oh, you mean you can't LEFT-click.
Do you have "Handle inventory clicks in scripts" activated in the General settings?
If so, you have to add a check for eMouseLeftInv in your on_mouse_click and handle inventory clicks yourself.
Edit:
For example:
//...
if (button == eMouseLeftInv) {
player.ActiveInventory = inventory[game.inv_activated]; // activate the clicked item
}
//...
Quote from: netmonkey's first postI have:
else if (button == eMouseLeftInv) {
if(mouse.Mode == eModeInteract) player.ActiveInventory = inventory[game.inv_activated];
else inventory[game.inv_activated].RunInteraction(mouse.Mode);
}
... on my on_mouse_click, but that's not doing the trick.
The only thing I can see is, it should be
Mouse.Mode - I'm not sure how case-sensitive it is about these things
Nope, the struct is named Mouse, but its instance is indeed called mouse.
Edit:
Hm, both seem to work. I'm confused now.
Just wanted to point out that reply #4, Strazer's, is exactly what I meant.
oh, I had it right, but the problem was with old code I added and forgot about:
else if (button == eMouseLeft || button == eMouseLeftInv ) {
//...
}
else if (button == eMouseLeftInv) {
//...
}
Quote from: strazer on Sun 08/05/2005 20:22:13
Nope, the struct is named Mouse, but its instance is indeed called mouse.
Hm, both seem to work. I'm confused now.
static functions can be called on instances too, so in this case Mouse and mouse will both work