Discussion:
help on UNDO of my Copy-Paste-Cut and Undo...form.
(too old to reply)
Ivan Benttini
2008-11-13 05:29:14 UTC
Permalink
Hello every one.

I have a form with a menu attached.
On the MENU
COPY_CUT_PASTE_UNDO works just right.

This form has also 4 buttons (COPY-CUT-PASTE-UNDO)
Copy, Cut, Paste also works just FINE, however the UNDO
does NOT.

Does any one knows why, since the 3 bottoms works OK?
It that something to do with the UNDO on the FORM, since on
the MENU it works OK?


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////// Here is the code on the form
///////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
this.rowset = this.employees1.rowset
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function BITMAPFIRST1_onOpen
form.employees1.rowset.first()
if form.employees1.rowset.endOfSet
form.employees1.rowset.first()
msgbox="You are at begining of file"
else
endif
return

function PUSHBUTTON1_onClick //copy
if type( "form.activeControl.copy" ) == "FP"
form.activeControl.copy()
form.PUSHBUTTON1.setfocus()
endif
return

function PUSHBUTTON2_onClick //cut
if type( "form.activeControl.cut" ) == "FP"
form.activeControl.cut()
form.PUSHBUTTON2.setfocus()
endif
return

function PUSHBUTTON3_onClick //paste
if type( "form.activeControl.paste" ) == "FP"
form.activeControl.paste()
form.PUSHBUTTON3.setfocus()
endif
return

function PUSHBUTTON4_onClick //UNDO .....HERE IS MY PROBLEM
FOR NOW.....
if type( "form.activeControl.undo" ) == "FP"
form.activeControl.undo()
form.PUSHBUTTON4.setfocus()
endif
return

function form_onOpen
this.root.EDITUNDOMENU:=this.root.EDIT.UNDO
this.root.EDITCOPYMENU:=this.root.EDIT.COPY
this.root.EDITCUTMENU:=this.root.EDIT.CUT
this.root.EDITPASTEMENU:=this.root.EDIT.PASTE
return
endclass

/////////////////////////////////////////////////////////////////////////////////////////////////
///// Here is also the code about the menu in the form ////////////////
///////////////////// 2nd class on the form
////////////////////////////////////////
Parameter FormObj,PopupName
NEW EDINFOPOPUP(FormObj,PopupName)
CLASS EDINFOPOPUP(FormObj,PopupName) OF POPUP(FormObj,PopupName)
this.Left = 0
this.Top = 0
this.TrackRight = .F.
this.Alignment = 1
this.OnInitMenu = CLASS::ROOT_ONINITMENU

DEFINE MENU COPY OF THIS;
PROPERTY;
Text "Copy",;
OnClick {; form.activeControl.Copy()}

DEFINE MENU PASTE OF THIS;
PROPERTY;
Text "Paste",;
OnClick {; form.activeControl.Paste()}

DEFINE MENU CUT OF THIS;
PROPERTY;
Text "Cut",;
OnClick {; form.activeControl.Cut()}

DEFINE MENU UNDO OF THIS;
PROPERTY;
Text "Undo",;
OnClick {; form.activeControl.Undo()} //<<<< this is the one not
working >>>> //////////

Procedure ROOT_OnInitMenu
control=form.activeControl
ctrl= control.className $ "ENTRYFIELD|EDITOR|BROWSE|GRID"
this.Cut.enabled = ctrl
this.Copy.enabled = ctrl
this.Paste.enabled = ctrl
this.Undo.enabled = ctrl
this.PASTE_SPECIAL.enabled = ctrl
endclass


/////////////////////////////////////////////////////////////////////////////////////////////
/////// ...and here is my menu CODE, (want I say my, I am not
/////// taking any credit, this is all thanks to the generosity of
/////// this group ( my life line ).
/////////////////////////////////////////////////////////////////////////////////////////////
** END HEADER -- do not remove this line
//
// Generated on 02/25/2008
//
parameter formObj
new TRYTHISMENU(formObj, "root")

class TRYTHISMENU(formObj, name) of MENUBAR(formObj, name)
this.FILE = new MENU(this)
with (this.FILE)
text = "File"
endwith

this.FILE.ABORT = new MENU(this.FILE) ////
with (this.FILE.ABORT) ////
onClick = class::ABORT_ONCLICK1 ////
text = "Abort"
////
endwith
////

////
this.FILE.CLOSE = new MENU(this.FILE) //// this 2 are
the same for now!
with (this.FILE.CLOSE) ////
onClick = class::CLOSE_ONCLICK1 ////
text = "Close" ////
endwith ////

this.EDIT = new MENU(this)
with (this.EDIT)
text = "Edit"
endwith

this.EDIT.UNDO = new MENU(this.EDIT)
with (this.EDIT.UNDO)
text = "Undo"
endwith

this.EDIT.CUT = new MENU(this.EDIT)
with (this.EDIT.CUT)
text = "Cut"
endwith

this.EDIT.COPY = new MENU(this.EDIT)
with (this.EDIT.COPY)
text = "Copy"
endwith

this.EDIT.PASTE = new MENU(this.EDIT)
with (this.EDIT.PASTE)
text = "Paste"
endwith

////////////////////////////////////////////////////// Functions and
Procedures ///////////////////////
function ABORT_onClick1
form.CLOSE()
return

function CLOSE_onClick1
form.CLOSE()
return
endclass
Bruce Beacham
2008-11-14 09:38:05 UTC
Permalink
Post by Ivan Benttini
I have a form with a menu attached.
On the MENU
COPY_CUT_PASTE_UNDO works just right.
This form has also 4 buttons (COPY-CUT-PASTE-UNDO)
Copy, Cut, Paste also works just FINE, however the UNDO
does NOT.
Does any one knows why, since the 3 bottoms works OK?
It that something to do with the UNDO on the FORM, since on
the MENU it works OK?
Does UNDO work from the popup menu?


Bruce Beacham
Ivan Benttini
2008-11-14 16:20:58 UTC
Permalink
Hi Bruce, thanks for helping.
I do not have any popMenu attached to my form, I do have a menu(.mnu ) only, but remember
the UNDO called from the menu(.mnu) WORKS fine, my problem is the UNDO called from the
pushButton4 on the Form, as below:
Thanks for taking the time to help me.
Ivan

class trythisForm of FORM
with (this)
onOpen = class::FORM_ONOPEN
onClose = class::FORM_ONCLOSE
height = 1.4091
left = 30.0
top = 4.0
width = 22.8571
text = "The test CUT-COPY-PASTE-UNDO"
background = "filename Beige2.jpg"
autoCenter = true
mdi = false
menuFile = "TryThis.mnu"
icon = "resource #21"
enabled = true
endwith

function PUSHBUTTON4_onClick //undo
if type( "form.activeControl.undo" ) == "FP"
form.activeControl.undo()
form.PUSHBUTTON4.setfocus()
endif
return

//////////////////THIS IS ALSO ON THE FORM WHEN THE FORM OPENS://////////////////
function form_onOpen
this.root.EDITUNDOMENU:=this.root.EDIT.UNDO
this.root.EDITCOPYMENU:=this.root.EDIT.COPY
this.root.EDITCUTMENU:=this.root.EDIT.CUT
this.root.EDITPASTEMENU:=this.root.EDIT.PASTE
return
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Bruce Beacham
2008-11-15 08:34:13 UTC
Permalink
Post by Ivan Benttini
Hi Bruce, thanks for helping.
I do not have any */popMenu/* attached to my form, I do have a
*/menu(.mnu )/* only, but remember
the */UNDO/* called from the menu(.mnu) WORKS fine, my problem is the
*/UNDO/* called from the
Oh, I saw this in your post:

NEW EDINFOPOPUP(FormObj,PopupName)
CLASS EDINFOPOPUP(FormObj,PopupName) OF POPUP(FormObj,PopupName)

- and assumed you had a popup menu in the form.


Bruce

Loading...