How do I create a new type (sub-class) of textedit field?

Norman,
are any unused images etc also stripped out before compiling if unused - or is it only subclasses which are stripped out?

Is this really true? (stripping of dead code that is)…
and is is why I ask

a) It has been said Xojo does not yet have a true optimizing compiler (and I thought that was a feature of such a compiler)
b) I created a project with ONE method with a very distinct name… and upon examining the compiled code inside the bundle… that name was in the code… had it stripped the un-used method… I would have thought it would not have appeared.

You’re testing the wrong thing
Code is NOT stripped at the METHOD level (note I never said it was)
Unused modules and unused classes will be

OK, back to my original questions: I created a new textfield called UpperText, put a keydown event me.text=me.text.uppercase and it works. Of course it shows on the window as an unnecessary field, but I guess I can make it invisible. But now to the second step of making some real text fields with it as the super. When I create a new field named CompName its a textfield by default, but when i change the super to UpperText and press return, it beeps and converts back to textfield as the super. How do I successfully give that (and other fields) the super of UpperText, which is the point of the whole thing anyway? Thanks in advance for any help.

I think you are missing the point of this subclass.
You do not create “textfields” with this class as its “super”.

You just USE that class INSTEAD of TextField. Anywhere you want this “special” textfield, drag your class there…

This of TextField as the “father” (or mother I guess) of your subclass… It has inherited all the “genes” from the parent (ie. Super) and has the addtional features you added to it.

You don’t make a control instance, you make a brand new control (that happens to inherit from an existing control - the textfield). Use Add Class to create a new class in the project pane / navigator, and change its name to UpperText and its super to TextField. Add your code to this new class - in the navigator, not the window editor.

[quote=79462:@Dave S]Depends on how you want to manage them.

If you use EXPORT, then each custom class is a file of its own, and you can use the operating system file management to organize them

If you store them in a special XOJO project, the you can organize them that way (and who care how big THAT project gets)… just copy and paste between that project file, and you new project file.[/quote]

You can also add those custom class files to the template project as external items, then when you update one of the files, the changes will appear in all projects with that external item. Also, the project files will not grow as much since they only have a reference to the external file and don’t contain all the code.

Better put the code in TextChange. This way it works even if the user modifies the text with paste.

Thanks for the replys. I believe this is a case of '‘how do I get there from here’. I know I have to create a new class, that’s what I’m trying to do. But I don’t find a button that says ‘Create Class’, so I don’t know where to do this. So since I have created textfields by dragging a control from the library to the window, I tried that; and since they all have supers, I tried changing the super of this new control to UpperText instead of TextField. But in won’t change, it goes right back to TextField. So there must be some other place/way to do this. I can’t get there from the Library, or the Inspector, or the Navigator. How? Where? Thanks in advance for the help. Hope to get past this problem soon.

Menu top of screen

INSERT -> CLASS

Instead of dragging the textfield to the window, drag it to the left hand side of the IDE, over CONTENTS. This will create a class named CustomTextField which is your parent class. It already has its super set to TextField, no need to go through creating a new class.

Add whatever events you need to the parent class, change its name as you wish, then when you want to use a subclass, drag that over your window and it will automagically inherit all the qualities of its parent.

In a way, you build your own library in the left hand side of the IDE this way.

Voila! and a whole new world opens to me. Thanks very much Dave and Michel. Now it works perfect and I understand a lot more. Most of my other custom fields are just different masks. But one is for TitleCase (1st letter of each word caps, rest lower) which will be a little more complex to do.

I don’t want to get too complicated and confuse you, but consider creating a single subClass with, let’s say “maskMode as integer” property. Then in the textChange event, you can look at that property to see what the current mode is and do the appropriate processing (take a look at select case). If you right-click on the subclass in the project pane and select “Inspector Behavior”, you can check the box for maskMode and add an enumeration for the various modes you’ll implement. This will allow you to add the custom control to a window and set the mode in the inspector pane. In this way you have a single class rather than several to keep track of.

TitleCase is built in.

me.Text = TitleCase(me.Text)

Tim, thanks for reminding me, I had forgotten that. I stopped using RB a couple years ago when it was very difficult to do nice reports (like MS Access), and then started with LiveCode. In LiveCode it doesn’t have TitleCase, so I had to roll my own. I’m hopeful that Xojo’s reporting abilities have much improved in the meantime.

There are certainly many more options than there were

Good to know. I’ll be looking for them right after I master using a database with Xojo; soon I hope.