Has it got UNDO function alike Ctrl+Z in :TGet? I cannot find it.
Thank you in advance for any suggestion and idea.
Dutch
oGet:Undo()
nageswaragunupudi wrote:Please try
- Code: Select all Expand view RUN
oGet:Undo()
// 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
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.
#Define VK_Z 26 // 538 ?
SetKey( VK_Z, {|| IF( GetKeyState( VK_CONTROL ), MY_FUNCTION(), NIL ) } )
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()
oGet:cText := oGet:uOriginalValue
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.
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 ) } )
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
oGet:undo() -> works
oGet:cText := v:oGet:Original -> works
oGet:bKeyChar := { |k,f,o| If( k == 26, ( o:cText := o:uOriginalValue, 0 ), nil ) }
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 ) }
Can it do in TGet classes?
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 104 guests