[Gambas-devel] User Control
Benoît Minisini
gambas at ...1...
Mon Feb 27 11:05:56 CET 2012
Le 27/02/2012 11:00, LJMA at ...689... a écrit :
> Hi,
>
> I have some problems when creating a user control. To give an example to make it clearer questions:
>
>
> Export
>
> Public Const _Properties As String = "*,Obligatorio=True,Tipo{Class1.*},Tipo2{Class2.*}"
> Public Const _IsControl As Boolean = True
> Public Const _DrawWith As String = "TextBox"
> Private hObs As Observer
> Property Obligatorio As Boolean
> Private $Obligatorio As Boolean
> Property Tipo As String
> Private $Tipo As String
> Property Tipo2 As Integer
> Private $Tipo2 As Integer
>
> Public Sub _new()
> hObs = New Observer(Me) As "TextBox" '
> Super.background =&FFFFFF&
> End
>
>
> Public Sub TextBox_GotFocus()
> Last.background =&9FFFFF&
> End
>
> Public Sub TextBox_lostFocus()
> Last.background =&FFFFFF&
> If Me.Obligatorio = True Then
> Super.background =&FF0000&
> else
> Super.background =&FFFFFF&
> Endif
> End
>
> Private Function Obligatorio_Read() As Boolean
> Return $Obligatorio
> End
>
> Private Sub Obligatorio_Write(Value As Boolean)
> $Obligatorio = Value
> End
>
> Private Function Tipo_Read() As String
> Return $Tipo
> End
>
> Private Sub Tipo_Write(Value As String)
> $Tipo = Value
> End
>
> Private Function Tipo2_Read() As Integer
> Return $Tipo2
> End
>
> Private Sub Tipo2_Write(Value As Integer)
> $Tipo2 = Value
> End
>
> la Clase Class1:
>
> Public Const Entero As String = "Entero"
> Public Const Float As String = "Float"
> Public Const Cadena As String = "Cadena"
>
> La Clase Class2:
>
> Public Const Entero As Integer = 0
> Public Const Float As Integer = 1
> Public Const Cadena As Integer = 2
>
>
> This code creates a user component that is placed in blue when it receives focus and should be red when
> you loseif the property "Obligatorio" is True.
>
> As you can see, by default,this property is True. Although set to True at design time, thenat runtime does not catch this value,
> takealways False. It's like missing code to assign the property values assigned at design time to
> property variables.
>
>
> Nor does it create a property with a list of options. According to the How To:
>
> For properties that take their value into a list of predefined
> constants of the same class, you can specify a class instead of a
> property kind, with an optional list of constants.
> Class . ( * | Constant1 ; Constant2 ; ... ) [ = Default ]
> The IDE will will use a ComboBox control to edit the value of the property, and will fill it with the specified constants.
>
>
>
> Any idea what I'm doing wrong?
>
> Thanks for your help.
>
You didn't care enough with the big yellow message in the documentation!
:-) Telling the IDE that the property default value is TRUE is not
enough. You must initialize the property with that default value in the
code too.
So you have to write that:
Private $Obligatorio As Boolean = True
Regards,
--
Benoît Minisini
More information about the Devel
mailing list