[Gambas-devel] User Control

LJMA at ...689... LJMA at ...689...
Mon Feb 27 11:00:35 CET 2012


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 lose if the property "Obligatorio" is True.

As you can see, by default, this property is True. Although set to True at design time, then at runtime does not catch this value, 
take always 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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/devel/attachments/20120227/b02eaed2/attachment.html>


More information about the Devel mailing list