Author Topic: Left Mouse Button for GUI ".accelerator"  (Read 816 times)

So, I have this GUI where I click at any time somewhere on the GUI while it is open, and a action happens.
I've tried setting .accelerator for a control to 'mouse0' and other stuff, but nuthin' works.

What is the correct 'key name' for LMB?

The accelerator option only applies to the keyboard.

You should be using a GuiMouseEventCtrl.

So, GuiMouseEventCtrl object here.accelerator = mouse0;?

EDIT: That didn't work.
« Last Edit: September 29, 2010, 06:55:06 AM by Bauklotz »

No - GuiMouseEventCtrl has callbacks for mouse events. Look up some documentation for it.

I tried looking at a documentation and used
Code: [Select]
function some_object_name_here::onMouseDown(%this,%mod,%pos,%click)
{
    // DOSTUFF
}

But "// DOSTUFF" wasn't executed when I pressed down left mouse button.

Well I use them all over RTB so you're doing something wrong.

You can use GuiMouseEventCtrl::onMouseDown(%this), but ObjectName::onMouseDown(%this) doesn't work at all

ie, they don't seem to inherit properly at all.

Code: [Select]
function GuiMouseEventCtrl::onMouse*(%this,%what,%ever,%else)
{
   if(%this.getName() !$= "")
   {
      if(isFunction(%this.getName(),"onMouse*"))
      {
         eval(%this @ ".onMouse*(" @ %this @ "," @ %what @ "," @ %ever @ "," @ %else @ ");");
      }
   }
}
Copy-paste for each action (* being Down, Up, Enter, Leave, four copies)
I'm using that and it works fine (even though I'm only using %this and no other arguments)

Package it otherwise you'll break every other mod that uses the same methods.

Well, I got this working and 'HI' was echoed to console.

Code: [Select]
package onMouse
{
    function GuiMouseEventCtrl::onMouseDown(%this,%mod,%pos,%click)
    {
        if(%this.getName() $= "some_name_here")
            echo(HI);
        else
            Parent::onMouseDown(%this,%mod,%pos,%click);
    }
};
activatePackage(onMouse);

But the problem is, clicking a not-on-top GuiMouseEventCtrl doesn't have any effect, and what I want to do is that I am making a new GuiBitmapCtrl that follows the mouse when I press a key, and the GuiMouseEventCtrl is re-made on top and follows too, but "HI" is not printed to console when clicking.