Página 1 de 1

IDEInspector - how to change TLabel:cText?

Publicado: Mié Feb 16, 2022 4:47 am
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,

Re: IDEInspector - how to change TLabel:cText?

Publicado: Lun Feb 28, 2022 4:35 pm
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,

Re: IDEInspector - how to change TLabel:cText?

Publicado: Lun Feb 28, 2022 7:17 pm
por ignacio
Hi,

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

Regards,

Re: IDEInspector - how to change TLabel:cText?

Publicado: Lun Feb 28, 2022 8:14 pm
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

Re: IDEInspector - how to change TLabel:cText?

Publicado: Lun Feb 28, 2022 8:25 pm
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

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

Re: IDEInspector - how to change TLabel:cText?

Publicado: Lun Feb 28, 2022 10:12 pm
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,

Re: IDEInspector - how to change TLabel:cText?

Publicado: Dom Jun 05, 2022 3:35 am
por Hurricane
hi,
any information about?