Custom class and UI interaction?

Woohoo! I’m immortal!

Thanks guys, will go over it in more detail tomorrow but need to leave it for now.

Markus and Amando,
It is apparent from your inability to understand my suggestion that you have never used Event Definitions. Whether or not you are interested, I am going to expand a bit. I programmed in RB for about 8 years and never understood event definitions. At the RealWorld in Austin in '08 I attended a talk by Guyren Howe and he opened my eyes to the power of event definitions. He stated that he consider them to be the most powerful feature of (at that time) RB. I am not proposing subclassing a window and there is no need to write the raiseevent code 24 times.

  1. Create a new class and give it the superclass TextField
  2. Select your class and do an “Add To…” and select Event Definition ( not Event Handler…Event Definition)
  3. Create your new event and name it anything you want (for this expl. we’ll call it mTxtChged)
  4. Now drag an instance of your new class onto your window. You can drag as many instances as you need. If all instances will respond in exactly the same way, I suggest making them a control set.
  5. Now go to the textChanged event of your subclass. If there are things you want all of your instances of this class to do, you can put them here. After that code put raiseevent mTxtChged
  6. Now go back to your window which contains instances of your subclass. Select Add To… and choose Event Handler. You will see that your new event mTxtChanged is one of the choices.
  7. Put code here that you want the instances on this window to all do when this is fired.
  8. The power of this technique is that when you drag your subclass to another window and implement this event, you can have that window do something entirely different if you choose.

I hope this helps someone down the road in using Xojo.

Your suggestion is already implemented in the example. Have you taken the time to examine to code I posted before making such false assumptions?

As I am sure you haven’t, please see my code, examine it, and then make your suggestions.
Here to download the code

Then feel free to make comments “after” you have seen the code. If you were, you wouldn’t write that message.

I have +10 years experience developing Xojo commercial applications I clearly know how event definitions works. And Markus as well without doubt.

Your proposal doesn’t work for what Markus needs. Despite the time you insist, sorry… no… doesn’t fit with Markus requirements.

Thanks for the tutorial anyway, but we are no new users with Xojo, fortunately.

Hi Roger,

[quote=103635:@Roger Clary]Markus and Amando,
It is apparent from your inability to understand my suggestion that you have never used Event Definitions.[/quote]

That’s about the time frame we have been on the forums together :slight_smile:

I started in 2002 or 2003 with REALbasic 5 but was mostly doing on/off as time permits, so am not a professional.

I wasn’t at the talk but I read his OOP book which did the same to me.

And that’s where it falls down as (see above) that has a major impact on readability.

Basically adding a new TextChanged event isn’t helpful because it only shifts the problem, it doesn’t solve it.

I thought maybe there is some advanced elegant method that I haven’t mastered yet (and there are many I haven’t mastered) but alas it seems there isn’t such a magic bullet.

[quote=103425:@Eli Ott]I’d go with the control set, but I would use constants for the index:

// Defined as constants in the window, not in code
Const MassOfA = 4
Const MassOfC = 18

Mass(MassOfA).text = 123
Mass(MassOfC).text = 219[/quote]
This is how I do it on a number of similar scenarios. I define the constants in a global module. It is a bit more up-front code, but it keeps things neat.