Super Class Textfield.Text To use Text instead of String

  1. last week

    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..

  2. Norman P

    Mar 15 Pre-Release Testers, Xojo Pro we're off to see the wizard th...

    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

  3. Ivan T

    Mar 15 Pre-Release Testers

    @Etienne P iOS and Desktop / web App

    conditional compilation?

  4. Wayne G

    Mar 15 Pre-Release Testers, Xojo Pro New Zealand axisdirect.nz

    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.

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

  6. Jürg O

    Mar 16 Pre-Release Testers, Xojo Pro

    @Etienne P 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

    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
  7. 24 hours ago

    @Jürg O I don't see why that would not work. I've just quickly tried - seems to work just fine:

    MyModelClass
    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

    The properity name is "Text"

    like : TextField.Text

    As Normand said, I can't use it :-(

or Sign Up to reply!