Pegar portapapeles sobre un TGet

Pegar portapapeles sobre un TGet

Postby Jaime Irurzun » Fri Dec 09, 2005 11:27 pm

Hola,

Parece que algo no funciona bien al pegar el contenido del portapapeles (previamente copiado desde la barra de direcciones del navegador de internet) sobre un TGet. Resulta que únicamente copia un trozo y no todo el contenido del string. Este es el TGet:

REDEFINE GET aGet[03] ;
VAR cInDirecc ;
ID 102 ;
OF oDlg

El problema no puede estar en la longitud de cInDirecc, porque mide 60 y el texto que el pegado del TGet realiza medirá unos 30 (el texto que realmente debería pegar es mayor que 30, ese es el problema, que no lo pega entero).

El problema viene reportado de un usuario que en anteriores versiones (compiladas con FWH anteriores) le funcionaba bien. ¿Ha habido algún cambio en TGet? ¿A qué se puede deber? ¿Puedo solucionarlo temporalmente de alguna forma? Muchas gracias.
Jaime Irurzun
 
Posts: 6
Joined: Thu Oct 06, 2005 8:01 pm

Postby Antonio Linares » Sat Dec 10, 2005 8:37 am

Jaime,

Acabo de probar samples\TestGet2.prg y he pegado en el primer GET la dirección que muestra el navegador al leer este post, y lo ha pegado bien.

¿ Que versión de Harbour/xHarbour usas ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41439
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby fgondi » Sat Dec 10, 2005 9:24 am

Hola,

A mi se me producia ese problema cuando el get contenia espacios.
Por ejemplo, lo tengo inicializado a 60 espacios e intento pegar cualquier cosa en él.
Para probar si es eso, selecciona todo el contenido del get (los espacios) antes de pegar, de esa forma se pegará el contenido sin tener en cuenta los espacios.

Para evitar tener que seleccionar el campo antes de pegar he realizado los siguientes cambios en la clase tget:

He redefinido la clase RButtonDown para que no llame a las opciones por defecto (mis clientes usan botón derecho para copiar/pegar):
Code: Select all  Expand view
METHOD RButtonDown( nRow, nCol, nFlags ) CLASS TGGet
   local oMenu, oClp, cText
   if GetFocus() != ::hWnd
      ::SetFocus()
      SysRefresh()              // In case there is a VALID somewhere
      if GetFocus() != ::hWnd
         return nil
      endif
   endif

   if ::bRClicked != nil
      return Eval( ::bRClicked, nRow, nCol, nFlags )
   endif

   DEFINE CLIPBOARD oClp OF Self FORMAT TEXT
   MENU oMenu POPUP
      if ::SendMsg( EM_UNDO ) != 0
         #ifndef __XPP__
            MENUITEM "Deshacer" ACTION ::UnDo()
         #else
            MENUITEM "Deshacer" ACTION ::TGet:UnDo()
         #endif
      else
         #ifndef __XPP__
            MENUITEM "Deshacer" ACTION ::UnDo() DISABLED
         #else
            MENUITEM "Deshacer" ACTION ::TGet:UnDo() DISABLED
         #endif
      endif

      SEPARATOR

      if ! Empty( ::GetSel() ) .and. !::lReadOnly
         #ifndef __XPP__
            MENUITEM "Cortar"  ACTION ::Cut()
         #else
            MENUITEM "Cortar"  ACTION ::TGet:Cut()
         #endif
      else
         #ifndef __XPP__
            MENUITEM "Cortar"  ACTION ::Cut() DISABLED
         #else
            MENUITEM "Cortar"  ACTION ::TGet:Cut() DISABLED
         #endif
      endif

      if ! Empty( ::GetSel() )
         #ifndef __XPP__
            MENUITEM "Copiar" ACTION ::Copy()
         #else
            MENUITEM "Copiar" ACTION ::TGet:Copy()
         #endif
      else
         #ifndef __XPP__
            MENUITEM "Copiar" ACTION ::Copy() DISABLED
         #else
            MENUITEM "Copiar" ACTION ::TGet:Copy() DISABLED
         #endif
      endif

      if ! Empty( oClp:GetText() ) .and. !::lReadOnly
         #ifndef __XPP__
            MENUITEM "Pegar" ACTION ::Paste()
         #else
            MENUITEM "Pegar" ACTION ::TGet:Paste()
         #endif
      else
         #ifndef __XPP__
            MENUITEM "Pegar" ACTION ::Paste() DISABLED
         #else
            MENUITEM "Pegar" ACTION ::TGet:Paste() DISABLED
         #endif
      endif

      if ! Empty( ::GetSel() ) .and. !::lReadOnly
         #ifndef __XPP__
            MENUITEM "Borrar" ACTION ::Del()
         #else
            MENUITEM "Borrar" ACTION ::TGet:Del()
         #endif
      else
         #ifndef __XPP__
            MENUITEM "Borrar" ACTION ::Del() DISABLED
         #else
            MENUITEM "Borrar" ACTION ::TGet:Del() DISABLED
         #endif
      endif

      SEPARATOR
      #ifndef __XPP__
         MENUITEM "Imprimir" ACTION ::Print()
      #else
         MENUITEM "Imprimir" ACTION ::TGet:Print()
      #endif
      SEPARATOR

      #ifndef __XPP__
         MENUITEM "Seleccionar todo" ACTION ::SelectAll()
      #else
         MENUITEM "Seleccionar todo" ACTION ::TGet:SelectAll()
      #endif
   ENDMENU
   ACTIVATE POPUP oMenu AT nRow, nCol OF Self
return 0


Y lo mas importante he cambiado en el método Paste la siguiente instrucción
cTemp = ::GetText()
por
cTemp = Alltrim(::GetText())

Code: Select all  Expand view
METHOD Paste( cText ) CLASS TGet

   local oClp
   local cTemp

   DEFINE CLIPBOARD oClp OF Self FORMAT TEXT

   if cText == nil
      if oClp:Open()
         cText = oClp:GetText()
         oClp:Close()
      else
         MsgAlert( "The clipboard is not available!" )
      endif
   endif

   if ! Empty( cText )
      cTemp = Alltrim(::GetText())    //... fgondi
      do case
         case ValType( cTemp ) == "C"
              ::oGet:Buffer = SubStr( cTemp, 1, ::nPos - 1 ) + Trim( cText ) + ;
                        SubStr( cTemp, ::nPos )

         case ValType( cTemp ) == "N"
              cTemp = cValToChar( cTemp )
              ::oGet:Buffer = Val( SubStr( cTemp, 1, ::nPos - 1 ) + Trim( cText ) + ;
                             SubStr( cTemp, ::nPos ) )

         case ValType( cTemp ) == "D"
              cTemp = cValToChar( cTemp )
              ::oGet:Buffer = CToD( SubStr( cTemp, 1, ::nPos - 1 ) + Trim( cText ) + ;
                              SubStr( cTemp, ::nPos ) )
      endcase

      ::DispText() // from buffer to screen

      // EMW - the text has been changed!
      if ::bChange != nil
         Eval( ::bChange,,, Self )
      endif

   endif

return nil
Un saludo
Fernando González Diez
ALSIS Sistemas Informáticos
User avatar
fgondi
 
Posts: 694
Joined: Fri Oct 07, 2005 6:58 am
Location: Palencia, España


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 38 guests