jcarmody Posted December 21, 2010 Report Share Posted December 21, 2010 I'm trying to help in this thread and came to a roadblock. I want to be able to examine the Label.Text of any GObject that has a Label.Text property without using a Case Structure to handle every type as I did in my solution there. My thought was that I could use the Class ID property of the GObject to cast the reference to the specific type of object and check if it has a Label.Text property. This brings up a few questions: Is it possible to get a type-specific Constant Refnum from the Class ID? How? Once I have the Constant Refnum, how can I get keep the property node from breaking (see below)? Quote Link to comment
ShaunR Posted December 21, 2010 Report Share Posted December 21, 2010 (edited) Deleted-Irrelevant post Edited December 21, 2010 by ShaunR Quote Link to comment
Black Pearl Posted December 21, 2010 Report Share Posted December 21, 2010 Is it possible to get a type-specific Constant Refnum from the Class ID? How? Once I have the Constant Refnum, how can I get keep the property node from breaking (see below)? 1. Hmm, I get from ClassName 'BooleanConstant' and the like. But your code in the other thread already does this, so propably I misunderstand your question. 2. Not possible. Constant has the Lable property, it's parent GObject has not. Other childs of GObject have it as well, but you need to downcast them explecite as well. Felix Quote Link to comment
crelf Posted December 21, 2010 Report Share Posted December 21, 2010 Constants might only have a label if you've created one (ie: right-click, show label). I've had similar issues when trying to get a caption of a FP control that doesn't have one. Quote Link to comment
Yair Posted December 21, 2010 Report Share Posted December 21, 2010 If they all have the Label.Text property, you can type cast the reference to a class which has it (e.g. the Control class) and use it with that. Note that type casting references can be dangerous, so if you want to be safe, I would go with trying TMSC down to each relevant class until you don't get an error or get the class ID to know which specific class it is. If you do use the type cast method, I suggest you only use it for the Label.Text property and then go back to working with the original reference. Quote Link to comment
Francois Normandin Posted December 21, 2010 Report Share Posted December 21, 2010 I'm trying to help in this thread and came to a roadblock. I want to be able to examine the Label.Text of any GObject that has a Label.Text property without using a Case Structure to handle every type as I did in my solution there. My thought was that I could use the Class ID property of the GObject to cast the reference to the specific type of object and check if it has a Label.Text property. This brings up a few questions: Is it possible to get a type-specific Constant Refnum from the Class ID? How? Once I have the Constant Refnum, how can I get keep the property node from breaking (see below)? You can relink the Label.Text property by setting the StringID of the "Property Item". However, it seems that there is a bug with writing the Property Item String ID for Text Label... I can change easily the property of the node by giving the correct String ID for any top-level property such as Indicator or KeyFocus, but when I input the string ID of any property that is a child of another property (ex: Label >> Text), then it returns an error. Perhaps I don't do it right, but I presume it has to do with the fact that the "All Supported Properties" doesn't return the children... So a workaround would be to set the Property Node for "Label" (string ID: 6332005) and then add a property node for Text... 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.