Page 1 of 1

Paste not working properly

Posted: Mon Jun 03, 2019 5:37 am
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

Re: Paste not working properly

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

Maybe try focusing the Editor first?

Code: Select all

Editor.Focus()
Cheers,
Alex

Re: Paste not working properly

Posted: Mon Jun 03, 2019 9:06 am
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:

Re: Paste not working properly

Posted: Mon Jun 03, 2019 9:09 am
by Sasha - Tracker Dev Team
:)

Re: Paste not working properly

Posted: Mon Jun 03, 2019 9:28 am
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

Re: Paste not working properly

Posted: Mon Jun 03, 2019 9:38 am
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

Re: Paste not working properly

Posted: Mon Jun 03, 2019 9:40 am
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

Re: Paste not working properly

Posted: Mon Jun 03, 2019 9:43 am
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

Re: Paste not working properly

Posted: Mon Jun 03, 2019 9:49 am
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

Re: Paste not working properly

Posted: Mon Jun 03, 2019 11:16 am
by cew
Any further ideas?

Re: Paste not working properly

Posted: Mon Jun 03, 2019 12:59 pm
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

Re: Paste not working properly

Posted: Mon Jun 03, 2019 1:05 pm
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

Re: Paste not working properly

Posted: Mon Jun 03, 2019 1:39 pm
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

Re: Paste not working properly

Posted: Mon Jun 03, 2019 1:47 pm
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

Re: Paste not working properly

Posted: Mon Jun 03, 2019 1:52 pm
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

Re: Paste not working properly

Posted: Mon Jun 03, 2019 1:55 pm
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

Re: Paste not working properly

Posted: Mon Jun 03, 2019 2:10 pm
by cew
I got it, thank you!

Best regards
cew

Re: Paste not working properly  SOLVED

Posted: Mon Jun 03, 2019 2:42 pm
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

Re: Paste not working properly

Posted: Wed Jun 05, 2019 6:57 am
by cew
Thank you for your help :)

Best regards
cew

Re: Paste not working properly

Posted: Wed Jun 05, 2019 7:21 am
by Sasha - Tracker Dev Team
:)