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.

Code Editor - new button, no duplication

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

Code Editor - new button, no duplication

Mensaje por Hurricane »

Hi,

I added a button to my routine in Code Editor, but how to make it not duplicate when compiling the plugin?

With two lines of code, I improvised and it works fine:

Código: Seleccionar todo

function install_ColorPicker(self)
   local oBand

   AEval( ::IEditor:oRebar:aItems, {|o|IF(HB_IsChar(o:cargo) .and. o:cargo == UTIL_NAME, o:oControl:end(), /*NIL*/)} ) // improvisation. it works and it doesn't blink.
   //AEval( ::IEditor:oRebar:aItems, {|o|IF(HB_IsChar(o:cargo) .and. o:cargo == UTIL_NAME, o:free(), )} )              // does not work.

   oBand:=::IEditor:oRebar:addItem()
   oBand:cargo:=UTIL_NAME             // improvisation

   ::addUtility( UTIL_NAME )

   WITH OBJECT TToolBar():New( ::IEditor:oRebar )
      :Create()
      :AddButton( "", "clrpicker",,, 'Color Picker'):onClick:={|| dlgColorPicker(self) }
   END

   return nil
I tried to create a better way. Creating a list of objects for UnRegister to destroy. It worked... but it makes all the Code Editor toolbar blink:

Código: Seleccionar todo

function install_ColorPicker(self)
   local oBand

   oBand:=::IEditor:oRebar:addItem()

   ::addUtility( UTIL_NAME )

   WITH OBJECT TToolBar():New( ::IEditor:oRebar )
      :Create()
      :AddButton( "", "clrpicker",,, 'Color Picker'):onClick:={|| dlgColorPicker(self) }
   END
   ::addEnd(oBand:oControl) // for UnRegister to destroy
   //::addEnd(oBand)        // does not work.
   return nil

METHOD addEnd( o ) CLASS MCPlugin
   if HB_IsObject(o)
      AAdd(::aEndList, o)
   endif
   return nil

METHOD unRegister() CLASS MCPlugin
   local nPos
   
   for nPos:=1 TO Len(::aEndList)
      TRY
         //::aEndList[nPos]:free()
         ::aEndList[nPos]:end()
         ::aEndList[nPos]:=nil
      END
   next
   ::aEndList:={}
   return ::Super:unRegister()
regards,
Developments | Trainings | Projects
Site | E-mail | Messenger | YouTube
Responder