Pass object to a Wnd |
Author: |
Message: |
Shondoit
Full Member
Hmm, Just Me...
Posts: 227 Reputation: 15
36 / /
Joined: Jul 2006
|
O.P. Pass object to a Wnd
I need some kind of method, to pass a custom Object to a PlusWnd, so I can use it again when the OnWindowEvent_CtrlClicked event fires....
i.e.
code: function CreateWnd () {
MyObject = new Object()
MyObject.Name = "MyCustomObject"
MyObject.Param = "ParamValue"
var Wnd = MsgPlus.CreateWnd("windows.xml","settings")
Wnd.CustomObject = MyObject
}
function OnSettingsEvent_CtrlClicked (Wnd, ControlId) {
var MyObject = Wnd.CustomObject
Debug.Trace(MyObject.Name)
}
This doesn't work, but I need something that has the same effect
|
|
08-11-2006 01:56 PM |
|
|
-dt-
Scripting Contest Winner
;o
Posts: 1819 Reputation: 74
36 / /
Joined: Mar 2004
|
RE: Pass object to a Wnd
What i do is create a hidden field on the window (in the xml) set that to a random ID, then store the object in a global array with that ID then when my event fires i read the ID from the Window and look it up in the array
Happy Birthday, WDZ
|
|
08-11-2006 02:09 PM |
|
|
Shondoit
Full Member
Hmm, Just Me...
Posts: 227 Reputation: 15
36 / /
Joined: Jul 2006
|
O.P. RE: Pass object to a Wnd
I already considered that, but I need the object itself, I want it to be a standalone object, not dependant of any arrays.
i.e. I have a .js with the object constructor, etc. And the Window Events, and a seperate .js with nothing more than 'obj = new MyObject()'
But thanks anyway
|
|
08-11-2006 02:12 PM |
|
|
-dt-
Scripting Contest Winner
;o
Posts: 1819 Reputation: 74
36 / /
Joined: Mar 2004
|
RE: Pass object to a Wnd
well Wnd isnt a normal object, neither is any of the Plus! objects your only real way to do what you want is via what i said, which i dont see whats so wrong about it...
Happy Birthday, WDZ
|
|
08-11-2006 02:16 PM |
|
|
CookieRevised
Elite Member
Posts: 15517 Reputation: 173
– / /
Joined: Jul 2003
Status: Away
|
RE: Pass object to a Wnd
quote: Originally posted by Shondoit
I need some kind of method, to pass a custom Object to a PlusWnd, so I can use it again when the OnWindowEvent_CtrlClicked event fires....
i.e.
code: function CreateWnd () {
MyObject = new Object()
MyObject.Name = "MyCustomObject"
MyObject.Param = "ParamValue"
var Wnd = MsgPlus.CreateWnd("windows.xml","settings")
Wnd.CustomObject = MyObject
}
function OnSettingsEvent_CtrlClicked (Wnd, ControlId) {
var MyObject = Wnd.CustomObject
Debug.Trace(MyObject.Name)
}
This doesn't work, but I need something that has the same effect
make and declare your object variable as a global variable, not as a local one: code: var MyObject = new Object();
function CreateWnd () {
MyObject.Name = "MyCustomObject"
MyObject.Param = "ParamValue"
var Wnd = MsgPlus.CreateWnd("windows.xml","settings")
}
function OnSettingsEvent_CtrlClicked (Wnd, ControlId) {
Debug.Trace(MyObject.Name)
}
.-= A 'frrrrrrrituurrr' for Wacky =-.
|
|
08-11-2006 06:10 PM |
|
|
Shondoit
Full Member
Hmm, Just Me...
Posts: 227 Reputation: 15
36 / /
Joined: Jul 2006
|
O.P. RE: Pass object to a Wnd
Well, thats what I do now, but when you do it like this, you need to now the name of the global object, and I don't want that, I want the object itself, so a user can name it whatever he likes...
But I don't think it's possible...
Perhaps Patchou can add Arguments support for Windows, so you can pass Parameters to a Window object, Patchou?... How 'bout it?
|
|
08-11-2006 10:58 PM |
|
|
cooldude_i06
Full Member
I'm so cool I worry myself.
Posts: 272 Reputation: 9
– / / –
Joined: Sep 2003
|
RE: Pass object to a Wnd
quote: Originally posted by Shondoit
Well, thats what I do now, but when you do it like this, you need to now the name of the global object, and I don't want that, I want the object itself, so a user can name it whatever he likes...
But I don't think it's possible...
Perhaps Patchou can add Arguments support for Windows, so you can pass Parameters to a Window object, Patchou?... How 'bout it?
Yeah, I was also looking for a way to do this. It would be great if this could be extended for methods so you could add predefined methods for a Window object. Also it would be REALLY great if you could add methods to the Window class so that all windows will inherit that method(only in the current script ofcourse).
|
|
08-12-2006 05:40 AM |
|
|
CookieRevised
Elite Member
Posts: 15517 Reputation: 173
– / /
Joined: Jul 2003
Status: Away
|
RE: RE: Pass object to a Wnd
quote: Originally posted by cooldude_i06
quote: Originally posted by Shondoit
Well, thats what I do now, but when you do it like this, you need to now the name of the global object, and I don't want that, I want the object itself, so a user can name it whatever he likes...
But I don't think it's possible...
Perhaps Patchou can add Arguments support for Windows, so you can pass Parameters to a Window object, Patchou?... How 'bout it?
Yeah, I was also looking for a way to do this. It would be great if this could be extended for methods so you could add predefined methods for a Window object. Also it would be REALLY great if you could add methods to the Window class so that all windows will inherit that method(only in the current script ofcourse).
What you ask for is something entirly different than what Shondoit asks for, if I read correctly...
As a matter of fact, I don't know exactly what Shondoit tries to do though as his request is a bit vague and as it is now, it seems a bit pointless. A detailed example (pseudo-code) would be helpfull, Shondoit...
What you, cooldude_i06, ask for is adding your own methods and functions to the special interfaces of Messenger Plus!. I also requested a method for this some while ago here.
This post was edited on 08-13-2006 at 09:30 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
|
|
08-13-2006 09:28 AM |
|
|
Shondoit
Full Member
Hmm, Just Me...
Posts: 227 Reputation: 15
36 / /
Joined: Jul 2006
|
O.P. RE: Pass object to a Wnd
Well, actually, Cooldude wants the same as me, to pass parameters to the PlusWnd object...
Only he wants to pass a method, and I want to pass an Object
But your thread does the trick too, if it gets sorted out, that is
|
|
08-13-2006 12:46 PM |
|
|
CookieRevised
Elite Member
Posts: 15517 Reputation: 173
– / /
Joined: Jul 2003
Status: Away
|
RE: Pass object to a Wnd
quote: Originally posted by Shondoit
Well, actually, Cooldude wants the same as me, to pass parameters to the PlusWnd object...
Only he wants to pass a method, and I want to pass an Object
Which are totally two different things...
1) You don't pass methods, you add methods to existing objects.
A method is a function. It makes no sense to "pass" it to another object. "Passing" is a term used in context of variables and functions.
2) You don't pass stuff to windows, you pass stuff to functions.
A window isn't something which can perform stuff; it's a dead thing only visible on the screen. The functions supporting the window can perform stuff. Hence it makes no sense to pass something to "a window". You pass something to the function which controls the window.
And for this you don't need any fancy thing at all, just a global variable (which holds the object or whatever else) since those are the things which are "passed" to and used between functions.
So, the two things asked are in fact two different things (unless you or cooldude described something different than what you actually wanted).
As for your own problem, Shondoit, a detailed (pseudo-) code example would be very helpfull in explaining to us what you actually are trying to accomplish. And maybe in that way I also can explain better that the thing you ask for and what cooldude asks for is actually totally different.
---
To add your own methods to objects, you use the prototype method. eg: code: String.prototype.trim = function() {
return this.replace(/(^\s|\s$/g, "");
}
will add a trim method to the string object.
Note that the stuff which Plus! adds to JScript aren't objects but mainly interfaces, you can not use the protoype method to add your own methods to them...
This post was edited on 12-29-2006 at 11:45 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
|
|
08-13-2006 06:10 PM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|
|