Undo function (Ctrl+Z) in :TGet

Undo function (Ctrl+Z) in :TGet

Postby dutch » Sun Oct 31, 2021 2:28 am

Has it got UNDO function alike Ctrl+Z in :TGet? I cannot find it.

Thank you in advance for any suggestion and idea.
Dutch
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Undo function (Ctrl+Z) in :TGet

Postby nageswaragunupudi » Sun Oct 31, 2021 3:28 am

Please try
Code: Select all  Expand view  RUN

oGet:Undo()
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Undo function (Ctrl+Z) in :TGet

Postby dutch » Sun Oct 31, 2021 1:56 pm

Dear Master,

It doesn't work. Nothing change, any editing still the same. It doesn't change back to original.
nageswaragunupudi wrote:Please try
Code: Select all  Expand view  RUN

oGet:Undo()
 
Last edited by dutch on Sun Oct 31, 2021 2:07 pm, edited 1 time in total.
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Undo function (Ctrl+Z) in :TGet

Postby karinha » Sun Oct 31, 2021 2:00 pm

Code: Select all  Expand view  RUN


// By Marco Boschi

#Include "Fivewin.Ch"

#Define EM_SETSEL 177

FUNCTION main()

   LOCAL oDlg
   LOCAL oGet1, cGet1 := "Marco                "
   LOCAL oGet2, cGet2 := "Enrico               "
   LOCAL oGet3, cGet3 := "                     "

   DEFINE DIALOG oDlg

   @ 1,1 GET oGet1 VAR cGet1 OF oDlg UPDATE

   oGet1:bGotFocus := { || oGet1:PostMsg( EM_SETSEL, Len( RTrim( cGet1 ) ), 0 ) }

   oGet1:bRClicked := { || PopGet( oGet1 ) }

   @ 2,1 get oGet2 VAR cGet2 of oDlg UPDATE

   oGet2:bGotFocus := { || oGet2:PostMsg( EM_SETSEL, Len( RTrim( cGet2 ) ), 0 ) }

   oGet2:bRClicked := { || PopGet( oGet2 ) }

   @ 3,1 get oGet3 VAR cGet3 of oDlg UPDATE

   oGet3:bGotFocus := { || oGet3:PostMsg( EM_SETSEL, Len( RTrim( cGet3 ) ), 0 ) }

   oGet3:bRClicked := { || PopGet( oGet3 ) }

   ACTIVATE DIALOG oDlg CENTERED

RETURN NIL

FUNCTION POPGET( oGet )

   LOCAL oMenu

   MENU POPUP oMenu 2007

       MENUITEM "Cut"           ; // "Cortar"
          ACTION( oGet:Cut() )

       MENUITEM "Copy"          ; // "Copiar"
          ACTION( oGet:Copy() )

       MENUITEM "Paste"         ; // "Pegar"
          ACTION( cPaste( oGet ) )

       MENUITEM "Cancel"        ; // "Cancelar"
          ACTION( oGet:Undo() )

       MENUITEM "Empty"         ; // "Vacío"
          ACTION( sClear( oGet ) )

       MENUITEM "Select"        ; // "Seleccionar"
          ACTION oGet:PostMsg( EM_SETSEL, Len( RTrim( oGet:Varget() ) ), 0 )

       MENUITEM "Select all"    ; // "Seleccionar todo"
          ACTION( oGet:SelectAll() )

    ENDMENU

   oMenu:Activate( oGet:nBottom, oGet:nLeft, oGet )

RETURN NIL

FUNCTION sClear( oGet )

   M->xSvuotata := oGet:Varget()
   M->cGetCargo := oGet:Cargo

   oGet:VarPut( uValBlank( oGet:VarGet() ) )
   oGet:Refresh()

RETURN NIL

FUNCTION cPaste( oGet )

    LOCAL nLo, nHi

    oGet:GetSelPos( @nLo, @nHi )

    IF nHi != nLo

        oGet:GetDelSel( nLo, nHi )

    ENDIF

    oGet:EditUpdate()

    oGet:Paste()

RETURN NIL
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7828
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Undo function (Ctrl+Z) in :TGet

Postby dutch » Sun Oct 31, 2021 2:26 pm

Dear karinha,

Your sample is working and I got it. TGet:undo() must still TGet in Focus.

Is it possible to add Ctrl+Z to TGet for :undo()?

I try as below at the main but ;
1. it works in case of typing more charactor.
2. it doesn't work in case delete some charactor.

Code: Select all  Expand view  RUN
SETKEY( 26    , {|p, l, v| v:Undo() } )


karinha wrote:
Code: Select all  Expand view  RUN


// By Marco Boschi

#Include "Fivewin.Ch"

#Define EM_SETSEL 177

FUNCTION main()

   LOCAL oDlg
   LOCAL oGet1, cGet1 := "Marco                "
   LOCAL oGet2, cGet2 := "Enrico               "
   LOCAL oGet3, cGet3 := "                     "

   DEFINE DIALOG oDlg

   @ 1,1 GET oGet1 VAR cGet1 OF oDlg UPDATE

   oGet1:bGotFocus := { || oGet1:PostMsg( EM_SETSEL, Len( RTrim( cGet1 ) ), 0 ) }

   oGet1:bRClicked := { || PopGet( oGet1 ) }

   @ 2,1 get oGet2 VAR cGet2 of oDlg UPDATE

   oGet2:bGotFocus := { || oGet2:PostMsg( EM_SETSEL, Len( RTrim( cGet2 ) ), 0 ) }

   oGet2:bRClicked := { || PopGet( oGet2 ) }

   @ 3,1 get oGet3 VAR cGet3 of oDlg UPDATE

   oGet3:bGotFocus := { || oGet3:PostMsg( EM_SETSEL, Len( RTrim( cGet3 ) ), 0 ) }

   oGet3:bRClicked := { || PopGet( oGet3 ) }

   ACTIVATE DIALOG oDlg CENTERED

RETURN NIL

FUNCTION POPGET( oGet )

   LOCAL oMenu

   MENU POPUP oMenu 2007

       MENUITEM "Cut"           ; // "Cortar"
          ACTION( oGet:Cut() )

       MENUITEM "Copy"          ; // "Copiar"
          ACTION( oGet:Copy() )

       MENUITEM "Paste"         ; // "Pegar"
          ACTION( cPaste( oGet ) )

       MENUITEM "Cancel"        ; // "Cancelar"
          ACTION( oGet:Undo() )

       MENUITEM "Empty"         ; // "Vacío"
          ACTION( sClear( oGet ) )

       MENUITEM "Select"        ; // "Seleccionar"
          ACTION oGet:PostMsg( EM_SETSEL, Len( RTrim( oGet:Varget() ) ), 0 )

       MENUITEM "Select all"    ; // "Seleccionar todo"
          ACTION( oGet:SelectAll() )

    ENDMENU

   oMenu:Activate( oGet:nBottom, oGet:nLeft, oGet )

RETURN NIL

FUNCTION sClear( oGet )

   M->xSvuotata := oGet:Varget()
   M->cGetCargo := oGet:Cargo

   oGet:VarPut( uValBlank( oGet:VarGet() ) )
   oGet:Refresh()

RETURN NIL

FUNCTION cPaste( oGet )

    LOCAL nLo, nHi

    oGet:GetSelPos( @nLo, @nHi )

    IF nHi != nLo

        oGet:GetDelSel( nLo, nHi )

    ENDIF

    oGet:EditUpdate()

    oGet:Paste()

RETURN NIL
 


Regards, saludos.
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Undo function (Ctrl+Z) in :TGet

Postby karinha » Sun Oct 31, 2021 3:16 pm

Maybe:

Code: Select all  Expand view  RUN

#Define VK_Z 26  // 538  ?

   SetKey( VK_Z, {|| IF( GetKeyState( VK_CONTROL ), MY_FUNCTION(), NIL ) } )
 


http://forums.fivetechsupport.com/viewtopic.php?f=6&t=8985

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7828
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Undo function (Ctrl+Z) in :TGet

Postby nageswaragunupudi » Sun Oct 31, 2021 3:50 pm

dutch wrote:Dear Master,

It doesn't work. Nothing change, any editing still the same. It doesn't change back to original.
nageswaragunupudi wrote:Please try
Code: Select all  Expand view  RUN

oGet:Undo()
 


This is far better than oGet:Undo()

Code: Select all  Expand view  RUN

oGet:cText := oGet:uOriginalValue
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Undo function (Ctrl+Z) in :TGet

Postby dutch » Mon Nov 01, 2021 2:14 am

Dear Karinha,

SetKey() do not accept CTRL+Z. It doesn't go through My_Function().
karinha wrote:Maybe:

Code: Select all  Expand view  RUN

#Define VK_Z 26  // 538  ?

   SetKey( VK_Z, {|| IF( GetKeyState( VK_CONTROL ), MY_FUNCTION(), NIL ) } )
 


http://forums.fivetechsupport.com/viewtopic.php?f=6&t=8985

Regards, saludos.
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Undo function (Ctrl+Z) in :TGet

Postby dutch » Mon Nov 01, 2021 2:17 am

Dear Master,

Code: Select all  Expand view  RUN
oGet:undo() -> works
oGet:cText := v:oGet:Original -> works

// Do not response
SETKEY( 26    , {|p, l, v| GetUndo(v) } )  // or
SetKey( VK_Z, {|p, l, v| IF( GetKeyState( VK_CONTROL ), GetUndo(v), NIL ) } )
 

The problem is SetKey() do not accept CTRL+Z.

nageswaragunupudi wrote:
dutch wrote:Dear Master,

It doesn't work. Nothing change, any editing still the same. It doesn't change back to original.
nageswaragunupudi wrote:Please try
Code: Select all  Expand view  RUN

oGet:Undo()
 


This is far better than oGet:Undo()

Code: Select all  Expand view  RUN

oGet:cText := oGet:uOriginalValue
 
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Undo function (Ctrl+Z) in :TGet

Postby nageswaragunupudi » Mon Nov 01, 2021 3:34 am

oGet:undo() -> works

Works only when oGet has focus. By any chance/mistake if oGet:undo() is called when oGet is out of focus, unexpected and undesirable results can happen.

oGet:cText := v:oGet:Original -> works

This works always.

Actually, I am testing and considering changing Undo() method of TGet to implement the second logic.

Do not use SETKEY.
If you want to undo when the user presses Ctrl-Z while editing the Get, then
Code: Select all  Expand view  RUN

oGet:bKeyChar := { |k,f,o| If( k == 26, ( o:cText := o:uOriginalValue, 0 ), nil ) }
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Undo function (Ctrl+Z) in :TGet

Postby dutch » Thu Nov 04, 2021 3:51 pm

Dear Master,

Can it do in TGet classes?
nageswaragunupudi wrote:Do not use SETKEY.
If you want to undo when the user presses Ctrl-Z while editing the Get, then
Code: Select all  Expand view  RUN

oGet:bKeyChar := { |k,f,o| If( k == 26, ( o:cText := o:uOriginalValue, 0 ), nil ) }
 
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: Undo function (Ctrl+Z) in :TGet

Postby nageswaragunupudi » Fri Nov 05, 2021 2:40 am

Can it do in TGet classes?

Yes.
Posted after testing.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 95 guests

cron