Discussion:
Cut, copy, paste
(too old to reply)
Greg Hill
2008-09-22 18:43:08 UTC
Permalink
I am using some code in a cc to allow users to pull up a popup menu in an
editor control to cut, copy, paste into and out of an editor control.
Occasionally the user gets an error message "Variable undefined Paste"
when they use the paste option. The code for this menu option in my cc is
this.MENU3 = new MENU(this)
with (this.MENU3)
onClick = {;form.activeControl.paste()}
text = "Paste"
shortCut = "Ctrl+V"
endwith
The odd thing about the error message is it references a line number from
the .cfm for the form.
function form_readModal
form.form_init() << line referenced in error msg
return (super::readmodal())
This error does not always happen, only sometimes, but it always
references the init function in the .cfm.
Anyone have an idea on what the error message is trying to tell me?
Any and all ideas appreciated,
I believe it is caused by the fact that some objects are not supported for
copy paste, it returns something than a text string.

So, in the code you can use a try / catch to eliminate the error and even
better you can tell the end-user that nothing was copied, instruct the user
to highlight the text they want to copy first and the click copy.

Greg Hill
Mark
2008-09-22 19:55:31 UTC
Permalink
Greg,

Yes, that sounds right. Will give that a try.

Thanks,
Mark
Post by Greg Hill
I am using some code in a cc to allow users to pull up a popup menu in an
editor control to cut, copy, paste into and out of an editor control.
Occasionally the user gets an error message "Variable undefined Paste"
when they use the paste option. The code for this menu option in my cc is
this.MENU3 = new MENU(this)
with (this.MENU3)
onClick = {;form.activeControl.paste()}
text = "Paste"
shortCut = "Ctrl+V"
endwith
The odd thing about the error message is it references a line number from
the .cfm for the form.
function form_readModal
form.form_init() << line referenced in error msg
return (super::readmodal())
This error does not always happen, only sometimes, but it always
references the init function in the .cfm.
Anyone have an idea on what the error message is trying to tell me?
Any and all ideas appreciated,
I believe it is caused by the fact that some objects are not supported for
copy paste, it returns something than a text string.
So, in the code you can use a try / catch to eliminate the error and even
better you can tell the end-user that nothing was copied, instruct the user
to highlight the text they want to copy first and the click copy.
Greg Hill
Greg Hill
2008-09-22 20:09:34 UTC
Permalink
Post by Mark
Greg,
Yes, that sounds right. Will give that a try.
Let us know.

Greg Hill
Mark
2008-09-22 20:21:46 UTC
Permalink
Greg,

I tried the following:
onClick = {;TRY;form.activeControl.paste();CATCH (Exception e);msgbox("No text was copied. Please highlight some text, pick Copy or Cut, then pick Paste.");ENDTRY;}

But I get a crash error (Plus has encoutnerd an internal or operating system error..." When I switch it back to:

onClick = {;form.activeControl.paste()}

I get the Variable undefined Paste error. Maybe a codeblock cannot handle a Try catch?

Thanks again,
Mark
Post by Greg Hill
Post by Mark
Greg,
Yes, that sounds right. Will give that a try.
Let us know.
Greg Hill
Bruce Beacham
2008-09-23 12:37:28 UTC
Permalink
I am using some code in a cc to allow users to pull up a popup menu
in an editor control to cut, copy, paste into and out of an editor
control. Occasionally the user gets an error message "Variable
undefined Paste" when they use the paste option. The code for this
this.MENU3 = new MENU(this) with (this.MENU3) onClick =
{;form.activeControl.paste()}
As a diagnostic, why don't you send this to the Results Pane in the IDE:

onClick = {;? form.activecontrol.name ; form.activeControl.paste()}

Then you can see which control is mentioned just before a crash.
text = "Paste" shortCut = "Ctrl+V" endwith
The odd thing about the error message is it references a line number
from the .cfm for the form.
function form_readModal form.form_init() << line referenced in error
msg return (super::readmodal())
This error does not always happen, only sometimes, but it always
references the init function in the .cfm.
What's in form_init?


Bruce Baecham
Mark
2008-09-23 14:28:02 UTC
Permalink
Bruce,

I used the following solution:

onClick = {;IF TYPE("form.activeControl.paste") == "FP";form.activeControl.paste();ENDIF}

This prevents an error message. The problem occurred when user would use the copy() when the rowset was in edit mode, then would cancel the edit. When they cancel an edit, I change the focus in some cases for various reasons. In this case, the new focus was on a grid. But when they right click they were still getting a paste option even tho the editor control no longer had focus.

I would think that since the editor no longer has focus, a right click should not display the popup, but it does.

Any ideas on how I might prevent the popup once the editor lost focus?

Thanks,
Mark
Post by Bruce Beacham
I am using some code in a cc to allow users to pull up a popup menu
in an editor control to cut, copy, paste into and out of an editor
control. Occasionally the user gets an error message "Variable
undefined Paste" when they use the paste option. The code for this
this.MENU3 = new MENU(this) with (this.MENU3) onClick =
{;form.activeControl.paste()}
onClick = {;? form.activecontrol.name ; form.activeControl.paste()}
Then you can see which control is mentioned just before a crash.
text = "Paste" shortCut = "Ctrl+V" endwith
The odd thing about the error message is it references a line number
from the .cfm for the form.
function form_readModal form.form_init() << line referenced in error
msg return (super::readmodal())
This error does not always happen, only sometimes, but it always
references the init function in the .cfm.
What's in form_init?
Bruce Baecham
Bruce Beacham
2008-09-24 07:50:13 UTC
Permalink
Post by Mark
Any ideas on how I might prevent the popup once the editor lost focus?
Sorry, I've never used popups so I'm at base zero in knowing anything
about them.


Bruce
WJS
2008-09-24 17:25:30 UTC
Permalink
Post by Mark
Bruce,
onClick = {;IF TYPE("form.activeControl.paste") ==
"FP";form.activeControl.paste();ENDIF}
This prevents an error message. The problem occurred when user would use
the copy() when the rowset was in edit mode, then would cancel the edit.
When they cancel an edit, I change the focus in some cases for various
reasons. In this case, the new focus was on a grid. But when they right
click they were still getting a paste option even tho the editor control
no longer had focus.
I would think that since the editor no longer has focus, a right click
should not display the popup, but it does.
Any ideas on how I might prevent the popup once the editor lost focus?
Mark,
You have various options
In the popup's Root OnInitMenu you can disable the options. This is
especially true when the popup is attached as the FORM's popup

Example:
function ROOT_OnInitMenu
*-----------------------*
// Based on code in duflp: FormCntl.cc by Ken Mayer
l=true
control=form.activeControl
// You may put in any classname you want the popup to work on, All others
you do not want it to work, you just leave out.
ctrl= control.className $ "SPINBOX|ENTRYFIELD|WSEEKER|EDITOR|"
local cbv1, cbv2, cbv3
private oRef, oFirstObj
// code by Ken Mayer
if type("IsClipboardFormatAvailable") # "FP"
extern clogical IsClipboardFormatAvailable(cuint) user32
endif
cbv1 = IsClipboardFormatAvailable(1) // CF-Text
cbv2 = IsClipboardFormatAvailable(7) // CF_OEMTEXT
cbv3 = IsClipboardFormatAvailable(13) // CF_UNICODETEXT
if cbv1 = true or cbv2 = true or cbv3 = true // there is text in the
clipboard, so paste is enabled
l=true//oForm.pop1.m_paste.enabled = true
else
l=false//oForm.pop1.m_paste.enabled = false
endif
this.Cut.enabled = iif(ctrl=true AND l=true, true,false)
this.Copy.enabled = iif(ctrl=true AND l=true, true,false)
this.Paste.enabled = iif(ctrl=true AND l=true, true,false)
this.Undo.enabled = iif(ctrl=true AND l=true, true,false)

Another option is to attach the popup to a specific control only. This will
prevent it to show in any other control. See the dBullitin issue 16 how.
Wian
Mark
2008-09-24 17:45:29 UTC
Permalink
WJS,

Interesting stuff. I use several popups, and each of the options depend on the base class for that control, so I am somewhat familar with this process. But I will need to take a closer look at formcntl.cc cause I am using a different method for disabling options on my popup based on the baseclass.

Thanks,
Mark
Post by WJS
Post by Mark
Bruce,
onClick = {;IF TYPE("form.activeControl.paste") ==
"FP";form.activeControl.paste();ENDIF}
This prevents an error message. The problem occurred when user would use
the copy() when the rowset was in edit mode, then would cancel the edit.
When they cancel an edit, I change the focus in some cases for various
reasons. In this case, the new focus was on a grid. But when they right
click they were still getting a paste option even tho the editor control
no longer had focus.
I would think that since the editor no longer has focus, a right click
should not display the popup, but it does.
Any ideas on how I might prevent the popup once the editor lost focus?
Mark,
You have various options
In the popup's Root OnInitMenu you can disable the options. This is
especially true when the popup is attached as the FORM's popup
function ROOT_OnInitMenu
*-----------------------*
// Based on code in duflp: FormCntl.cc by Ken Mayer
l=true
control=form.activeControl
// You may put in any classname you want the popup to work on, All others
you do not want it to work, you just leave out.
ctrl= control.className $ "SPINBOX|ENTRYFIELD|WSEEKER|EDITOR|"
local cbv1, cbv2, cbv3
private oRef, oFirstObj
// code by Ken Mayer
if type("IsClipboardFormatAvailable") # "FP"
extern clogical IsClipboardFormatAvailable(cuint) user32
endif
cbv1 = IsClipboardFormatAvailable(1) // CF-Text
cbv2 = IsClipboardFormatAvailable(7) // CF_OEMTEXT
cbv3 = IsClipboardFormatAvailable(13) // CF_UNICODETEXT
if cbv1 = true or cbv2 = true or cbv3 = true // there is text in the
clipboard, so paste is enabled
l=true//oForm.pop1.m_paste.enabled = true
else
l=false//oForm.pop1.m_paste.enabled = false
endif
this.Cut.enabled = iif(ctrl=true AND l=true, true,false)
this.Copy.enabled = iif(ctrl=true AND l=true, true,false)
this.Paste.enabled = iif(ctrl=true AND l=true, true,false)
this.Undo.enabled = iif(ctrl=true AND l=true, true,false)
Another option is to attach the popup to a specific control only. This will
prevent it to show in any other control. See the dBullitin issue 16 how.
Wian
Loading...