In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

IDEInspector - how to change TLabel:cText?

Xailer professional forum in English
Responder
Avatar de Usuario
Hurricane
Mensajes: 262
Registrado: Mar Mar 24, 2015 10:21 am
Ubicación: Brasil
Contactar:

IDEInspector - how to change TLabel:cText?

Mensaje por Hurricane »

Hi,

I'm completing a new plugin...
how do I change the TLabel:cText value? that is in the Form Designer and reflect it in the Object Inspector.

regards,
Developments | Trainings | Projects
Site | E-mail | Messenger | YouTube
Avatar de Usuario
Hurricane
Mensajes: 262
Registrado: Mar Mar 24, 2015 10:21 am
Ubicación: Brasil
Contactar:

Re: IDEInspector - how to change TLabel:cText?

Mensaje por Hurricane »

Hi,
I need help on this to finalize my plugin.
The way I did it, it doesn't update in the Object Inspector, it only updates in the Form Designer*.

Código: Seleccionar todo

   with object oCtrl

      if :isKindOf('TLabelBuddy')

         oInspector:setControl(oCtrl)
         :cText:=Value

         //oInspector:setControl(oInspector:oActiveForm)
         //oInspector:setControl(oCtrl)
         //oPlugin:IEditor:lModified:=.t.
         oInspector:Refresh()
         
      //elseif :isKindOf('TLabel')

      endif

   end with
* When I recorded the video I posted yesterday, I was surprised because the update was working, but it will only happen with the new controller. If I close the PRG and load it into the Designer, it won't work.
Videos Xailer Harbour Brasil

regards,
Developments | Trainings | Projects
Site | E-mail | Messenger | YouTube
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9246
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: IDEInspector - how to change TLabel:cText?

Mensaje por ignacio »

Hi,

I guess that if you change the order it will work: Assign cText before oInspector:SetControl( oControl ) // not tested

Regards,
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Avatar de Usuario
Hurricane
Mensajes: 262
Registrado: Mar Mar 24, 2015 10:21 am
Ubicación: Brasil
Contactar:

Re: IDEInspector - how to change TLabel:cText?

Mensaje por Hurricane »

hi,
does not work, I had tested. The example I posted will work, but if I reload the PRG it doesn't.
ignacio escribió: Lun Feb 28, 2022 7:17 pm I guess that if you change the order it will work: Assign cText before oInspector:SetControl( oControl ) // not tested
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9246
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Re: IDEInspector - how to change TLabel:cText?

Mensaje por ignacio »

From ControlsInitProps plugin in samples:

Código: Seleccionar todo

/*
 * Proyecto: ControlsInitProps
 * Fichero: Main.prg
 * Descripción:
 * Autor:
 * Fecha: 14/01/2021
 */

#include "Xailer.ch"

#define TOOLTIP_ICONINFO        2266

DYNAMIC TIDEPlugin
memvar oInspector, oCode

//------------------------------------------------------------------------------

INIT PROC CIP_PluginRegister()

   WITH OBJECT TCIP_PlugIn():New()
      :cName := "ICIP_Plugin"
      :cDescription := "Valores iniciales de controles"
      :cVersion := "1.2"
      :cCategory := "Samples"
      :cImage := "ICIP_Plugin"
      :Install()
   END

RETURN

//------------------------------------------------------------------------------

CLASS TCIP_Plugin FROM TIDEPlugin

   DATA oMenuItem
   DATA oRunProject
   DATA oRunForm
   DATA cRunProjectName

   METHOD Install()
   METHOD GetInfo()
   METHOD Config()
   METHOD Run( oControl, aSelection )
   METHOD SaveState()
   METHOD LoadState()

ENDCLASS

//------------------------------------------------------------------------------

METHOD Run( oControl, aSelection )

   local lMod := .f.

   if oControl == NIL .OR. !::oMenuItem:lChecked
      return nil
   endif

   ::oRunForm        := oControl:oForm
   ::oRunProject     := NIL
   ::cRunProjectName := ""

   IF ::oRunForm != NIL
      ::oRunProject := ::oRunForm:oProject
      IF ::oRunProject != NIL
         ::cRunProjectName := ::oRunProject:cName
      endif
   ENDIF

   WITH OBJECT oControl
      IF :IsKindOf( "TLabel" )
         :cText := "My label" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< WORKING
         // We do nothing since lAutoSize should be enough
//         :nHeight := 20
         lMod := .T.
      ELSEIF :IsKindOf( "TEditMod" )
         // No hacer nada. Lo ponemos para que no salte la siguiente
      ELSEIF :IsKindOf( "TEdit" )
         :nHeight := 22
         lMod := .T.
      ELSEIF :IsKindOf( "TButton" )
         :nHeight := 30
         :nWidth  := 90
         lMod := .T.
      ELSEIF :IsKindOf( "TCheckBox" )
         :nHeight := 20
         lMod := .T.
      ELSEIF :IsKindOf( "TBrowse" )
         :nHeaderHeight := 30
         lMod := .T.
      ENDIF
   end with

   if lMod
      oInspector:SetControl( oControl )
      oCode:oOutputArea:NewTab( Lt( TOOLTIP_ICONINFO ), .F. ):Append( ;
        "Control modified by Plugin 'Controls Init'" + CRLF, 2 )
   ENDIF

return nil

//------------------------------------------------------------------------------

METHOD Install() CLASS TCIP_Plugin

   LOCAL oMenu := ::GetMainMenu():GetToolsMenu()

   ::RegisterMenuItem( oMenu:AddSeparator() )

   WITH OBJECT ::oMenuItem := TMenuItem():Create( oMenu, , , "Plugin: Controls Init Properties" )
      :OnClick := {|| ::Config() }
   END WITH

   ::LoadState()

   ::RegisterMenuItem( ::oMenuItem )

   ::cDescription := "Valores iniciales de controles"
   ::RegisterEvent( "FE_AddControl", {| oCtl, aSel | ::Run( oCtl, aSel ) } )
   ::Register()

RETURN Nil

//------------------------------------------------------------------------------

METHOD Config() CLASS TCIP_Plugin

   ::oMenuItem:lChecked := !::oMenuItem:lChecked
   ::SaveState()

return nil

//------------------------------------------------------------------------------

METHOD GetInfo() CLASS TCIP_Plugin

   LOCAL cInfo := "<b>Controls Init Properties</b>" + CRLF + ;
                  CRLF + ;
                  "Inicialización automática de ciertas propiedades de controles "+ ;
                  "cuando se añaden al formulario. Sólo configurable por código." + ;
                  + CRLF + CRLF + ;
                  "<b>Autor</b>: Ignacio Ortiz de Zúñiga" + CRLF + ;
                  "<b>Versión</b>: " + ::cVersion + CRLF + ;
                  "<b>Copyright</b>: 2021 Ignacio Ortiz de Zúñiga & Xailer"

RETURN cInfo

//------------------------------------------------------------------------------

METHOD LoadState() CLASS TCIP_Plugin

   LOCAL lState

   with object TIni():New( Application:cDirectory + "Xailer.cfg" )
      lState := :GetEntry( "PLUGINS", "ControlsInitPropertiesState", .F. )
      :End()
   END WITH

   ::oMenuItem:lChecked := lState

RETURN lState

//------------------------------------------------------------------------------

METHOD SaveState() CLASS TCIP_Plugin

   LOCAL lState := ::oMenuItem:lChecked

   with object TIni():New( Application:cDirectory + "Xailer.cfg" )
      :SetEntry( "PLUGINS", "ControlsInitPropertiesState", lState )
      :End()
   END WITH

RETURN lState

//------------------------------------------------------------------------------
Ignacio Ortiz de Zúñiga
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Avatar de Usuario
Hurricane
Mensajes: 262
Registrado: Mar Mar 24, 2015 10:21 am
Ubicación: Brasil
Contactar:

Re: IDEInspector - how to change TLabel:cText?

Mensaje por Hurricane »

Hi,
It's not the same thing, you're using an event for when you create a control.
I created a small complete example and sent it to you and José.

remember, also test your code with labels read from XFM (if you include labels, then close and reopen the PRG).
My code is working only with new controls inserted in the Form.
ignacio escribió: Lun Feb 28, 2022 8:25 pm From ControlsInitProps plugin in samples:
thanks,
Developments | Trainings | Projects
Site | E-mail | Messenger | YouTube
Avatar de Usuario
Hurricane
Mensajes: 262
Registrado: Mar Mar 24, 2015 10:21 am
Ubicación: Brasil
Contactar:

Re: IDEInspector - how to change TLabel:cText?

Mensaje por Hurricane »

hi,
any information about?
Responder