Paste not working properly  SOLVED

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
cew
User
Posts: 213
Joined: Tue Feb 01, 2011 8:14 am

Paste not working properly

Post by cew »

Hi there,

in scenario I have 2 instances of PDF editors in the UI.
If I call the paste command like:

Code: Select all

Editor.Inst.ExecUICmd("cmd.paste");
allways the editor gets the data from clipboard, that was focused by the user. Not the one that is referred to in my control.

Before calling the paste command, I set the input focus to the target editor, but this does not help.

Code: Select all

var doc = Editor.Doc;
doc.ActiveView.PagesView.Obj.SetInputFocus(true);
What's the trick?

Best regards
cew
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Paste not working properly

Post by Sasha - Tracker Dev Team »

Hello cew,

Maybe try focusing the Editor first?

Code: Select all

Editor.Focus()
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
cew
User
Posts: 213
Joined: Tue Feb 01, 2011 8:14 am

Re: Paste not working properly

Post by cew »

Sasha - Tracker Dev Team wrote: Mon Jun 03, 2019 8:43 am Hello cew,

Maybe try focusing the Editor first?

Code: Select all

Editor.Focus()
Cheers,
Alex
Life can be so easy :)

Thank you! Best care anywhere :wink:
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Paste not working properly

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
cew
User
Posts: 213
Joined: Tue Feb 01, 2011 8:14 am

Re: Paste not working properly

Post by cew »

Sorry, just worked the first time (???).
After restarting my application, the paste showed the same behaviour as before ... :(
Always the editor, that got the focus by user gets the pasted data...

Any ideas?

Best regards
cew
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Paste not working properly

Post by Sasha - Tracker Dev Team »

Hello cew,

How about getting the needed IPXV_MainView's IUIX_Obj and using the IUIX_Obj::SetInputFocus method?
Also, emulating the LMB click should also help.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
cew
User
Posts: 213
Joined: Tue Feb 01, 2011 8:14 am

Re: Paste not working properly

Post by cew »

Do you mean that what I posted in my initial question?

Code: Select all

var doc = Editor.Doc;
doc.ActiveView.PagesView.Obj.SetInputFocus(true);

Best regards
cew
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Paste not working properly

Post by Sasha - Tracker Dev Team »

Hello cew,

Yup, but try using both of the Editor.Focus() and doc.ActiveView.SetInputFocus(true) and see if it helps.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
cew
User
Posts: 213
Joined: Tue Feb 01, 2011 8:14 am

Re: Paste not working properly

Post by cew »

Sasha - Tracker Dev Team wrote: Mon Jun 03, 2019 9:43 am Hello cew,

Yup, but try using both of the Editor.Focus() and doc.ActiveView.SetInputFocus(true) and see if it helps.

Cheers,
Alex
Guess what I did :wink:
It does not help ...

Best regards
cew
cew
User
Posts: 213
Joined: Tue Feb 01, 2011 8:14 am

Re: Paste not working properly

Post by cew »

Any further ideas?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Paste not working properly

Post by Sasha - Tracker Dev Team »

Hello cew,

Let me understand what do you want to achieve. Do you want to achieve paste into the needed Editor Frame or do you think that there are several clipboards available for each of the frame?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Paste not working properly

Post by Sasha - Tracker Dev Team »

Hello cew,

Just tried of doing the paste command for two different frames - everything worked correctly.

Code: Select all

private void pasteIn0FrameToolStripMenuItem_Click(object sender, EventArgs e)
{
	pdfCtl.Inst.MainFrm[0].Obj.SetInputFocus(true);
	pdfCtl.Inst.ExecUICmd("cmd.paste");
}

private void pasteIn1FrameToolStripMenuItem_Click(object sender, EventArgs e)
{
	pdfCtl.Inst.MainFrm[1].Obj.SetInputFocus(true);
	pdfCtl.Inst.ExecUICmd("cmd.paste");
}
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
cew
User
Posts: 213
Joined: Tue Feb 01, 2011 8:14 am

Re: Paste not working properly

Post by cew »

Hi,

I encapsulated the Editor in an own control.
Two of these controls are placed nearby in my application.
On top of each control a have a button for selecting an image that will be copied to the clipboard an then the targeted editor will use the Paste command to get the grafic from the clipboard.
This works fine if there is just one editor available.
If I have two editor-controls, allways the editor gets the clipboard data, that has the focus. In the code I see, that the "left" editor ist used in code, but the "right" editor gets the graphic.

Example
MyPDFControl1.Paste() gets called,
but
MyPDFControl2 shows the result

Here's the Paste()-Method of the control:

Code: Select all

public AxPDFXEdit.AxPXV_Control Editor;

public void Paste() {
      Editor.Focus();
      var doc = Editor.Doc;
      doc.ActiveView.PagesView.Obj.SetInputFocus(true);
      Editor.Inst.ExecUICmd("cmd.paste");
}
I have no knowledge about the MainFrm-index you used to differ between the editors.

Best regards
cew
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Paste not working properly

Post by Sasha - Tracker Dev Team »

Hello cew,

The IPXV_Control is basically a helper with different methods and properties for easy usage. When it comes to multiple frames, you should not use the IPXV_Controls if you want to distinguish them but IPXV_MainFrame by index like I shown in the code sample. Try it and see whether this works for you.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
cew
User
Posts: 213
Joined: Tue Feb 01, 2011 8:14 am

Re: Paste not working properly

Post by cew »

How do I get the index of the current editor instance to be able to address the right editor using your code?

Best regards
cew
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Paste not working properly

Post by Sasha - Tracker Dev Team »

Hello cew,

You can obtain the ActiveMainFrm index from the IPXV_Inst, then you can get the frames count and you can check whether the active main frame pointer is equal to the 0 or 1 frame from the array.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
cew
User
Posts: 213
Joined: Tue Feb 01, 2011 8:14 am

Re: Paste not working properly

Post by cew »

I got it, thank you!

Best regards
cew
Last edited by cew on Mon Jun 03, 2019 2:52 pm, edited 1 time in total.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Paste not working properly  SOLVED

Post by Sasha - Tracker Dev Team »

Hello cew,

OK, in C++ it would sound like this - you should compare the pointer of the ActiveMainFrm to each of the IPXV_MainFrm in the IPXV_Inst::MainFrm array. I don't know whether you should convert this to object or IntPtr or something else in C# but the logic should be like that.
The ActiveMainFrm should give you that frame that currently has focus. If you need to do something in the other one - you can use the index to do the logic that you need. Basically having the index of the active frame, you can call something from the inactive one of you require that.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
cew
User
Posts: 213
Joined: Tue Feb 01, 2011 8:14 am

Re: Paste not working properly

Post by cew »

Thank you for your help :)

Best regards
cew
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Paste not working properly

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply