[SOLVED] mouse.IsButtonDown while over an inventory item?

Started by monkey0506, Sat 04/10/2008 20:21:11

Previous topic - Next topic

monkey0506

It's a bit bothersome to me that mouse.IsButtonDown doesn't work with eMouseLeftInv and eMouseRightInv which are essentially just eMouseLeft and eMouseRight over an inventory item. Logically I suppose you could say that mouse.IsButtonDown(eMouseLeftInv) would only return true if the button was being held over an inventory item, but simply testing mouse.IsButtonDown(eMouseLeft) returns false.

I've agreed to help subspark with a project of his which involves a verbcoin interface which he asked me to script. I've got a pretty functional albeit basic interface worked up, but it's no good without inventory functionality...

So basically all I need to know is if on_mouse_click is called with eMouseLeftInv or eMouseRightInv, is there any reasonable way for me to check the raw state of that mouse button being held?

Thanks for any assistance, especially if I'm just being dumb and missing something obvious/simple. :D

RickJ

Have you tried changing the "Handle Inventory Clicks in the script" option in General Settings?  I don't know if this will help or not.  :-\

monkey0506

#2
I imagined that having that setting turned off would mean that I wouldn't be activating on_mouse_click at all, but I can certainly look into it! :D

Any suggestions are definitely welcome, so thanks beforehand.

Edit: I actually managed to solve this one myself with a bit more thought...and the use of on_event. I'm still handling inventory clicks in the script, but I'm catching the clicks as part of the eEventGUIMouseDown event for the inventory GUI, like this:

Code: ags
function on_event(EventType event, int data) {
  if ((event == eEventGUIMouseDown) && (data == gInventory.ID)) {
    InventoryItem *iat = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
    if (iat != null) {
      if (mouse.IsButtonDown(eMouseLeft)) on_mouse_click(eMouseLeft);
      else if (mouse.IsButtonDown(eMouseRight)) on_mouse_click(eMouseRight);
    }
  }
}


It works perfect. Thanks again for the suggestion anyway Rick. ;)

SMF spam blocked by CleanTalk