Author Topic: Calling a function on click  (Read 3504 times)

I'm in a bit of a pickle;

When you open a GUI and click, no function is called.
Unless trace is lieing to me.

I need a way of calling a function when you click with a gui open.
The only way I can think is by creating a giant button, but that would screw everything up.
« Last Edit: February 01, 2008, 05:04:36 PM by MrPickle »

Looks like you're in a pickle.

Use a GuiInputCtrl:
Code: [Select]
...
new GuiInputCtrl(MyInputCtrl) {
profile = "GuiInputCtrlProfile";
horizSizing = "center";
vertSizing = "bottom";
position = "0 0";
extent = "64 64";
minExtent = "8 8";
visible = "1";
helpTag = "0";
};
...

function MyInputCtrl::onInputEvent(%this, %device, %action) {
   if( %device $= "mouse" && %action $= "button0" ) {
      // CLICK
   }
}
« Last Edit: February 01, 2008, 02:31:57 PM by exidyne »

Looks like you're in a pickle.

Thanks for your useful input as usual!

Trace isn't 'lieing' to you.

But you can use a GuiInputCtrl:
Code: [Select]
...
new GuiInputCtrl(MyInputCtrl) {
profile = "GuiInputCtrlProfile";
horizSizing = "center";
vertSizing = "bottom";
position = "0 0";
extent = "64 64";
minExtent = "8 8";
visible = "1";
helpTag = "0";
};
...

function MyInputCtrl::onInputEvent(%this, %device, %actino) {
   // One sec...
}

I'll take a look at that.

GuiInputCtrls seems to paralyze the mouse's ability to click.

Yeah, I see where it's going wrong. Getting warmer, though.

My guess is the profile or something.

Not that otherwise it wouldn't paralyze the mouse in Gui Editor, maybe it would, I dunno.
« Last Edit: February 01, 2008, 03:00:02 PM by MrPickle »

Quote
function MyInputCtrl::onInputEvent(%this, %device, %action) {
   // You had it as %actino
}

Try calling the parent::onInputevent so stuff works?

Or change the extent of it so it fills the GUI.

I'm not making it call any function, I just crate it and then the mouse doesn't click.

Exactly, oninputevent may be a hacky override of the Torque engine input devices - make it call parent::onInputEvent(%this,%device,%action); and nothing else.

So it constantly calls onInputEvent?

Looks like you're in a pickle.

Ephi, you are my hero.

MrPickle, I told you to start saying "I'm in a bit of a pickle." whenever you start a Coding Help topic.  You aren't doing your part.

Yeah, You have to take an opportunity like this - your name is a comedy goldmine, now get digging!

Erm, If I do it will you guys help please?

Perhaps, but we'd have to have a show of good faith . . . like you putting that phrase at the top of the first post of this topic.