Super Class Textfield.Text To use Text instead of String

I use a common class in iOS and Desktop / web App that i need to assign a Text format, but from Textfield and some other Controls in the Desktop and Web app, i can’t use directly the Text from the Control because it’s a string. I’m trying to superclass it, but «Text» is a Keyword

Exemple :

Window1
MyModelClass.APropertyText as text = TextField.Text as string

i can’t use .Text.ToText (because i would need to add that to 1100 other Controls)

I was wondering if is there a way to superclass the .Text

like

superclassTextField.Text as Text
do the conversion…

You definitely cant insert a superclass

And a subclass wont let you use Text as the name for a property, method etc since its a type name
I know a way to hack in a method overload for a subclass but I would not recommend it since it could break at any time

conditional compilation?

Convert your property to private and add two setters one that accepts text & another that accepts String and converts it to text defining the encoding. You may want to add a getter that returns the text property. Don’t forget to use the compatibility flags in the advanced section of the inspector to exclude the string setter from iOS projects.

Wayne,
it was a good idea, but the IDE said there already a setter with the same name :-/

I don’t see why that would not work. I’ve just quickly tried - seems to work just fine:

MyModelClass

[code]Private Property mAPropertyText as Text

Public Function APropertyText() as Text
return mAPropertyText
End Function

Public Sub APropertyText(Assigns psString As String)
me.mAPropertyText = psString.ToText
End Sub

Public Sub APropertyText(Assigns psText As Text)
me.mAPropertyText = psText
End Sub
[/code]

[quote=428910:@Jürg Otter]I don’t see why that would not work. I’ve just quickly tried - seems to work just fine:

MyModelClass

[code]Private Property mAPropertyText as Text

Public Function APropertyText() as Text
return mAPropertyText
End Function

Public Sub APropertyText(Assigns psString As String)
me.mAPropertyText = psString.ToText
End Sub

Public Sub APropertyText(Assigns psText As Text)
me.mAPropertyText = psText
End Sub
[/code][/quote]

The properity name is “Text”

like : TextField.Text

As Normand said, I can’t use it :frowning: