Posted 11 September 2020, 2:05 am EST
I am trying to do programmatic cut, copy and paste operations. I need these two operations to be distinct, however, and function as a typical cut, copy and paste might in any application. In other words:
- The user performs one actions to initiate the cut/copy, and a second to initiate the paste
- The cut/copy needs to place the data from the selected range into the clipboard so it can be accessed outside of SpreadJS if needed.
- The cut/copy triggers the dashed border around the selection.
- I need to be able to trigger identical behavior using both a context menu option and a keyboard shortcut (I believe I know how to do this).
Now, I have seen a number of similar questions on this forum, so before I get the same answer given here: https://www.grapecity.com/forums/spreadjs/copypaste-from-outside-spr (which is taken verbatim from documentation I have already read), let me be clear that this is NOT an answer to my question. I don’t know why that answer keeps getting recycled for posts about copy, but it very clearly mentions only the clipboardPaste command, and is doing single operation copy/pastes and cut/pastes. This does not meet my needs.
That being said, the documentation here: https://www.grapecity.com/spreadjs/docs/v13/online/SpreadJS~GC.Spread.Sheets.Commands_namespace.html very clearly indicates the existence of a distinct copy command. It does not, however provide any examples of its use or explain in any useful what how to use it. Does this command actually work? If so, how?
Furthermore, going back to the clipboardPastes mentioned above, EVERY example I have seen of that command’s use very clearly has a fromRanges and a pastedRanges parameter. This, implies then that there isn’t actually a “cliboardPaste” occurring, but rather some programmatic movement of data from one provided range to another. If it’s pasting from the clipboard, why do we need to provide a fromRange? If I omit the fromRange, does the command actually pull data from the clipboard? Is there some SpreadJS clipboard construct I need to provide to the command? Again, none of this is discussed in documentation.
I have also tried the commands used in the default context menus (gc.spread.contextMenu.copy and gc.spread.contextMenu.pasteXXX), but not only do they not work for my specific use case (I have a locked header row and this seems to cause issues with the paste), but it doesn’t actually seem like the gc.spread.contextMenu.copy operation copies to the clipboard (as when I try to paste outside SpreadJS, the pasted value is whatever I copied prior to triggering the gc.spread.contextMenu.copy).
I have also seen the copyTo() method, but again, I need distinct operations, not a single-click combined copy/paste.
So, to summarize:
- Can I please get a concrete example of how the copy command (GC.Spread.Sheets.Commands.copy) works?
- Can I please get a concrete example of how to use clipboardPaste (GC.Spread.Sheets.Commands.clipboardPaste), or a similar command (I see there is a straight paste command) to paste from the actual clipboard?
If the above commands are non-functional or for whatever reason cannot actually do clipboard operations, an acknowledgement of this would save me (and likely others) a lot of head banging.
- And if I can’t use your commands do do this, is there a way to programatically toggle the cutCopyIndicator so I can provide a visual cue that whatever manual implementation I come up with is actually doing something? (I see the docs here: https://www.grapecity.com/spreadjs/docs/v13/online/clipboard.html but they only discuss the boolean cutCopyIndicatorVisible, which seems like it determines if an indicator will be displayed when triggered, but does not do the actual triggering).
Thank you.