GUI Class / Method Problem
by Chris M. Fitzgerald · in Torque Game Builder · 09/26/2011 (11:34 am) · 3 replies
Greetings. Ran into a small problem. I created a button:
I then created a method for the class:
Clicking on the button results in:
input(0): unable to find object: 'blah' attempting to call function 'hi'
What's going on here ... ?
Thanks.
EDIT: The problem is most likely that this is a GUI object.
new GuiBitmapButtonCtrl(zug1) {
class = "blah";
command = "blah.hi(yo);"
};I then created a method for the class:
function blah::hi(%this,%meh){
echo("Hello there" SPC %meh);
}Clicking on the button results in:
input(0): unable to find object: 'blah' attempting to call function 'hi'
What's going on here ... ?
Thanks.
EDIT: The problem is most likely that this is a GUI object.
About the author
Something wicked this way comes.
#2
Yeah, that will probably work.
Bit, uh, rusty with OOP :)
09/26/2011 (3:05 pm)
Thank you for the response. Sorry about the stat papers. Zzz.Yeah, that will probably work.
Bit, uh, rusty with OOP :)
#3
09/28/2011 (10:39 am)
If you want to do it by class do this:new GuiBitmapButtonCtrl(zug1) {
class = "blah";
};
function blah::onClick(%this) {
// All buttons with "blah" for the class will call this.
}
function zug1::onClick(%this) {
// Only zug1 will call this. Will have to do:
// "Parent::onClick(%this)" to call the "blah" version.
// If you leave this function out, it will call the
// "blah" version.
}
Torque Owner Justin Proffitt
new GuiBitmapButtonCtrl(zug1) { class = "blah"; command = "zug1.hi(yo);" };I suspect it might work. As far as I am aware, it works the same way for all objects exposed to script, so GUI objects should (in this regard) act exactly the same as scene objects.
(I hope I don't sound condescending and apologize if it comes off that way, I just spent 3 hours reading heavy statistical papers and I think it rubs off)