Setting focus to opened PDF document
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.
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.
-
- User
- Posts: 518
- Joined: Thu Dec 06, 2007 8:13 pm
Setting focus to opened PDF document
I need assistance with being able to set focus to the Tab that was just opened so users can then use the keyboard arrows to browse the document. The default behavior is not this. Although the tab appears to be selected it really does not have the focus. We are using build .318.0 and have also tried using 318.1 but with the same results. We are using your SDK and have also confirmed this to not work in the PDF-XChange Editor.
Any code to help me select the tab after a document has been opened would be appreciated.
Ticket information.
"RT#3695 Editor Does not focus on Document when opened via File> Open"
Thanks.
Any code to help me select the tab after a document has been opened would be appreciated.
Ticket information.
"RT#3695 Editor Does not focus on Document when opened via File> Open"
Thanks.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Setting focus to opened PDF document
Hello docu-track99,
The pagesView pane highlighting can be achieved by using these two methods:
or
Cheers,
Alex
The pagesView pane highlighting can be achieved by using these two methods:
Code: Select all
Doc.ActiveView.Panes.Layout.HighlightPane(Doc.ActiveView.PagesView.Obj);
Code: Select all
pdfCtl.ShowPane("pagesView", true, true);
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 518
- Joined: Thu Dec 06, 2007 8:13 pm
Re: Setting focus to opened PDF document
Thanks Sasha,
I tried both methods in the pdfCTRL_OnEvent but it did not allow me to scroll the PDF after it was loaded. The suggestions were placed when Case pdfCtrl.Inst.Str2ID("e.document.viewingStarted") was the case.
So when Case pdfCtrl.Inst.Str2ID("e.document.viewingStarted") was true I am calling Me.SetFocusToOpenedPDF() and the method looks like this. Is this proper?
Private Sub SetFocusToOpenedPDF()
'Set focus to the PDF that was just opened so the
'user can begin navication with the keyboard.
'Method 1
pdfCtrl.ShowPane("pagesView", True, True)
'Method 2
'Dim oDoc As PDFXEdit.IPXV_Document = pdfCtrl.Doc
'oDoc.ActiveView.Panes.Layout.HighlightPane(oDoc.ActiveView.PagesView.Obj)
End Sub
I tried both methods in the pdfCTRL_OnEvent but it did not allow me to scroll the PDF after it was loaded. The suggestions were placed when Case pdfCtrl.Inst.Str2ID("e.document.viewingStarted") was the case.
So when Case pdfCtrl.Inst.Str2ID("e.document.viewingStarted") was true I am calling Me.SetFocusToOpenedPDF() and the method looks like this. Is this proper?
Private Sub SetFocusToOpenedPDF()
'Set focus to the PDF that was just opened so the
'user can begin navication with the keyboard.
'Method 1
pdfCtrl.ShowPane("pagesView", True, True)
'Method 2
'Dim oDoc As PDFXEdit.IPXV_Document = pdfCtrl.Doc
'oDoc.ActiveView.Panes.Layout.HighlightPane(oDoc.ActiveView.PagesView.Obj)
End Sub
-
- User
- Posts: 518
- Joined: Thu Dec 06, 2007 8:13 pm
Re: Setting focus to opened PDF document
One more note.
When the PDF does open I can use the wheel of the mouse to scroll in the PDF but not use the arrow keys. I have to click somewhere in the body of the PDF before the arrows work.
If you have not had a moment to refer to the ticket then this next point is important.
To reproduce:
- open the editor
- open a document from the open menu
- use keyboard arrow keys to navigate (this is where my problem is)
Thanks.
When the PDF does open I can use the wheel of the mouse to scroll in the PDF but not use the arrow keys. I have to click somewhere in the body of the PDF before the arrows work.
If you have not had a moment to refer to the ticket then this next point is important.
To reproduce:
- open the editor
- open a document from the open menu
- use keyboard arrow keys to navigate (this is where my problem is)
Thanks.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Setting focus to opened PDF document
Hello docu-track99,
I will consult with my teammate on this matter and will reply with the answer.
Cheers,
Alex
I will consult with my teammate on this matter and will reply with the answer.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Setting focus to opened PDF document
Hi docu-track99.
Currently you may try the next workaround:
HTH
The issue "RT#3695 Editor Does not focus on Document when opened via File> Open" will be fixed in the next build.To reproduce:
- open the editor
- open a document from the open menu
- use keyboard arrow keys to navigate (this is where my problem is)
Currently you may try the next workaround:
Code: Select all
' open the document ..
' set keyboard focus into pages view window
Dim Doc As PDFXEdit.IPXV_Document = pdfCtrl.Doc
Doc.ActiveView.PagesView.Obj.SetInputFocus(true);
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 518
- Joined: Thu Dec 06, 2007 8:13 pm
Re: Setting focus to opened PDF document
Vasyl,
This works.
I call it once I hit Case pdfCtrl.Inst.Str2ID("e.document.viewingStarted") in the pdfCtrl.OnEvent (e.nEventID)
Thanks.
This works.
I call it once I hit Case pdfCtrl.Inst.Str2ID("e.document.viewingStarted") in the pdfCtrl.OnEvent (e.nEventID)
Thanks.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Setting focus to opened PDF document
Glad that worked for you
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 518
- Joined: Thu Dec 06, 2007 8:13 pm
Re: Setting focus to opened PDF document
Sasha,
Not good news for you this time. The fix only works on 1/2 of the test environments we have at the office. We are getting success and failures on Windows 10 + Anniversary + all updates.
I went ahead and tried the code that worked with the SDK 318.1 but it still fails with the same machines here. Is there an ETA for the next SDK release?
Thanks,
docu-track99
Not good news for you this time. The fix only works on 1/2 of the test environments we have at the office. We are getting success and failures on Windows 10 + Anniversary + all updates.
I went ahead and tried the code that worked with the SDK 318.1 but it still fails with the same machines here. Is there an ETA for the next SDK release?
Thanks,
docu-track99
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Setting focus to opened PDF document
Hi docu-track99.
I must clarify one moment with that issue with setting input focus when document is opened:
- we will try fix it for our EU Editor as well.
- we will left it as is for SDK mode when document is opened programmatically. Otherwise many developers will be very surprised when input focus will be suddenly grabbed by our ActiveX Control from dev's UI, when document is opened...
Also: we reproduced your new issue with code
Doc.ActiveView.PagesView.Obj.SetInputFocus(true)
- and we will try to fix it near future..
Cheers.
I must clarify one moment with that issue with setting input focus when document is opened:
- we will try fix it for our EU Editor as well.
- we will left it as is for SDK mode when document is opened programmatically. Otherwise many developers will be very surprised when input focus will be suddenly grabbed by our ActiveX Control from dev's UI, when document is opened...
Also: we reproduced your new issue with code
Doc.ActiveView.PagesView.Obj.SetInputFocus(true)
- and we will try to fix it near future..
Cheers.
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Setting focus to opened PDF document
Please try next workaround (C# code):
pdfCtl.Inst.ProgressMon = null; // to prevent showing progress dialog
pdfCtl.OpenDocFromPath(fileName);
pdfCtl.Inst.ProgressMon = pdfCtl.Inst.DefaultProgressMon; // to restore default progress dialog
PDFXEdit.IPXV_Document Doc = pdfCtrl.Doc;
Doc.ActiveView.PagesView.Obj.SetInputFocus(true);
pdfCtl.Inst.ProgressMon = null; // to prevent showing progress dialog
pdfCtl.OpenDocFromPath(fileName);
pdfCtl.Inst.ProgressMon = pdfCtl.Inst.DefaultProgressMon; // to restore default progress dialog
PDFXEdit.IPXV_Document Doc = pdfCtrl.Doc;
Doc.ActiveView.PagesView.Obj.SetInputFocus(true);
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 518
- Joined: Thu Dec 06, 2007 8:13 pm
Re: Setting focus to opened PDF document
Hello Vasyl,
I tried the latest suggestion but it still does not work in all cases of Windows 10. Could development consider a property or new parameter in the load document method that will give developers the opportunity to set focus to the PDF after it has been loaded? The default behavior could be kept the same for other developers but allow us to control when to use it.
Could this work?
Thanks,
docu-track99
I tried the latest suggestion but it still does not work in all cases of Windows 10. Could development consider a property or new parameter in the load document method that will give developers the opportunity to set focus to the PDF after it has been loaded? The default behavior could be kept the same for other developers but allow us to control when to use it.
Could this work?
Thanks,
docu-track99
- Vasyl-Tracker Dev Team
- Site Admin
- Posts: 2353
- Joined: Thu Jun 30, 2005 4:11 pm
- Location: Canada
Re: Setting focus to opened PDF document
The code:Could development consider a property or new parameter in the load document method that will give developers the opportunity to set focus to the PDF after it has been loaded?
Doc.ActiveView.PagesView.Obj.SetInputFocus(true);
- must work correctly in all cases. If is is not working in all cases - there is a bug and it should be fixed. Problem is that we cannot reproduce your problem with my latest workaround - that is strange..
Can you provide some details about test-machines on which you are able to reproduce that issue? Also: can you reproduce such issue with our FullDemo app (with my latest workaround too)?
----
Sure, in the future we may add new easy method to set input focus for the document like doc.SetInputFocus() - but it will call the same doc.ActiveView.PagesView.Obj.SetInputFocus() in most cases..
Vasyl Yaremyn
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Tracker Software Products
Project Developer
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 9
- Joined: Wed Mar 29, 2017 1:36 am
Re: Setting focus to opened PDF document
Doc.ActiveView.PagesView.Obj.SetInputFocus(true) works to focus the PDF document, but how can I set the focus to a specific form field (IPXC_AcroForm)?
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Setting focus to opened PDF document
Hello JSantmann@Wellsoft.com,
The specific from field is not a IPXC_AcroForm but a IPXC_FormField. Also, each form field has an annotation widget (IPXC_Annotation). So what you can do is create a new https://sdkhelp.pdf-xchange.com/vi ... tSelection and select the needed widgets.
Cheers,
Alex
The specific from field is not a IPXC_AcroForm but a IPXC_FormField. Also, each form field has an annotation widget (IPXC_Annotation). So what you can do is create a new https://sdkhelp.pdf-xchange.com/vi ... tSelection and select the needed widgets.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 9
- Joined: Wed Mar 29, 2017 1:36 am
Re: Setting focus to opened PDF document
Hi Alex,
Yes, I meant IPXC_FormField.
So if I have an IPXC_FormField, it is still not clear to me how to use IPXV_AnnotSelection to set the form field as active/focused. Nearest I can tell, there is essentially no documentation describing what IPXV_AnnotSelection is, or how to use it.
From IPXC_FormField I can get an enumerate of Widgets using Widgets[nIndex: ULONG_T] and WidgetsCount, but then what? I have a list of Widgets, but what do they represent and how do I use them?
In the forums, there are examples of how to use widgets to do various other things, but I have not been able to find any documentation telling me exactly what a Widget is or why there are multiple widgets per form field. The online help, for the most part, only has what's already in the PDFXEdit_TLB.Pas file.
By the way, I should add that I think that the XChange Editor tool is really impressive piece of work. It's very robust, stable and comprehensive; but I sure wish there was more documentation.
Thanks for your help.
- John
Yes, I meant IPXC_FormField.
So if I have an IPXC_FormField, it is still not clear to me how to use IPXV_AnnotSelection to set the form field as active/focused. Nearest I can tell, there is essentially no documentation describing what IPXV_AnnotSelection is, or how to use it.
From IPXC_FormField I can get an enumerate of Widgets using Widgets[nIndex: ULONG_T] and WidgetsCount, but then what? I have a list of Widgets, but what do they represent and how do I use them?
In the forums, there are examples of how to use widgets to do various other things, but I have not been able to find any documentation telling me exactly what a Widget is or why there are multiple widgets per form field. The online help, for the most part, only has what's already in the PDFXEdit_TLB.Pas file.
By the way, I should add that I think that the XChange Editor tool is really impressive piece of work. It's very robust, stable and comprehensive; but I sure wish there was more documentation.
Thanks for your help.
- John
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Setting focus to opened PDF document
Hello John,
Also, you can read about widgets here:
http://www.adobe.com/content/dam/acom/e ... 13.1951506
I misinterpreted what you have meant by focus. Here's what you should try - get widget of the needed form field, then create and fire the https://sdkhelp.pdf-xchange.com/vi ... cusChanged event while passing this widget as a first parameter. This should work.
Cheers,
Alex
Also, you can read about widgets here:
http://www.adobe.com/content/dam/acom/e ... 13.1951506
I misinterpreted what you have meant by focus. Here's what you should try - get widget of the needed form field, then create and fire the https://sdkhelp.pdf-xchange.com/vi ... cusChanged event while passing this widget as a first parameter. This should work.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Setting focus to opened PDF document
Hi Alex! I'm trying to follow this thread and do what I think you said to do. Here's my code:
The goal is to set the input focus to an IPXC_FormField. The above code doesn't work.
What else needs to be done to make this work?
Thanks.
Code: Select all
procedure SetFieldFocused(const AFieldName: UnicodeString);
var
fld: IPXC_FormField;
core: IPXC_Document;
acro: IPXC_AcroForm;
annot: IPXC_Annotation;
id: UINT;
event: IEvent;
begin
if AFieldName = '' then
raise Exception.Create('Error: Field name must be specified.');
core := FPDFEdit.Doc.CoreDoc;
if core.HasAcroForm then
begin
FPDFEdit.Doc.ActiveView.PagesView.Obj.SetInputFocus(True);
acro := core.AcroForm;
fld := acro.GetFieldByName(PChar(AFieldName));
annot := fld.Widget[0];
begin
id := FPDFEdit.Inst.Str2ID('e.document.fieldFocusChanged',False);
event := FPDFEdit.Doc.EventServer.CreateNewEvent(id,0,0);
FPDFEdit.Doc.EventServer.FireEvent(event,annot);
end;
end;
end;
What else needs to be done to make this work?
Thanks.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Setting focus to opened PDF document
Hello dkeith2,
You forgot to:
Cheers,
Alex
You forgot to:
In the CreateNewEvent method.while passing this widget as a first parameter
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Setting focus to opened PDF document
Tried this, still doesn't work:
I couldn't find any examples nor documentation on how to... cast(?) the ipxc_annotation(widget) for param1. Can you please provide an example of the proper way to do this?
One of the things that I noticed in the interface is that the IPXV_TextEditor give access to an IUIX_Edit, which in turn inherits from IUIX_ObjImpl, which has an Obj property that provides access to the SetInputFocus method. Problem is, I don't know how to connect to an IPXC_FormField's IUIX_Edit object, without accessing the IPXV_TextEditor via the ActiveTextEditor. Of course the ActiveTextEditor is read only - as it should be, I guess - but that means that I can't SET the ActiveTextEditor, nor have I been able to find a way to get access to an IPXC_FormField's IUIX_Edit interface.
Thanks.
Code: Select all
procedure SetFocused(const AFieldName: WideString);
var
fld: IPXC_FormField;
core: IPXC_Document;
acro: IPXC_AcroForm;
annot: IPXC_Annotation;
id: UINT;
event: IEvent;
begin
core := FPDFEdit.Doc.CoreDoc;
if core.HasAcroForm then
begin
FPDFEdit.Doc.ActiveView.PagesView.Obj.SetInputFocus(True);
acro := core.AcroForm;
fld := acro.GetFieldByName(PChar(AFieldName));
annot := fld.Widget[0];
id := FPDFEdit.Inst.Str2ID('e.document.fieldFocusChanged',False);
event := FPDFEdit.Doc.EventServer.CreateNewEvent(id,LongWord(annot),0);
FPDFEdit.Doc.EventServer.FireEvent(event,annot);
end;
end;
One of the things that I noticed in the interface is that the IPXV_TextEditor give access to an IUIX_Edit, which in turn inherits from IUIX_ObjImpl, which has an Obj property that provides access to the SetInputFocus method. Problem is, I don't know how to connect to an IPXC_FormField's IUIX_Edit object, without accessing the IPXV_TextEditor via the ActiveTextEditor. Of course the ActiveTextEditor is read only - as it should be, I guess - but that means that I can't SET the ActiveTextEditor, nor have I been able to find a way to get access to an IPXC_FormField's IUIX_Edit interface.
Thanks.
- Tracker Supp-Stefan
- Site Admin
- Posts: 17906
- Joined: Mon Jan 12, 2009 8:07 am
- Location: London
- Contact:
Re: Setting focus to opened PDF document
Hello dkeith2,
Alex is away till Monday, so he has asked me to let you know that he will be able to look at this once he is back!
Regards,
Stefan
Alex is away till Monday, so he has asked me to let you know that he will be able to look at this once he is back!
Regards,
Stefan
Re: Setting focus to opened PDF document
Thanks, looking forward to Alex' response.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Setting focus to opened PDF document
Hello dkeith2,
Here's how you should do it:
Cheers,
Alex
Here's how you should do it:
Code: Select all
PDFXEdit.PXC_Rect rc;
PDFXEdit.IPXC_Document coreDoc = CreateNewDocument(out rc);
PDFXEdit.IPXC_FormField ff = coreDoc.AcroForm.CreateField("Edit1", PDFXEdit.PXC_FormFieldType.FFT_Text, 0, ref rc);
PDFXEdit.IPXC_Annotation annot = ff.Widget[0];
pdfCtl.OpenDocFrom(coreDoc);
//You'll need this block
int nSelID = pdfCtl.Inst.Str2ID("selection.annots", false);
PDFXEdit.IPXV_AnnotSelection itSel = (PDFXEdit.IPXV_AnnotSelection)pdfCtl.Doc.CreateStdSel((uint)nSelID);
//Insert needed widgets
itSel.Items.Insert(annot);
pdfCtl.Doc.ActiveSel = itSel;
itSel.Show(true);
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Re: Setting focus to opened PDF document
Awesome! That works well.
Thank you!
Thank you!
- TrackerSupp-Daniel
- Site Admin
- Posts: 8586
- Joined: Wed Jan 03, 2018 6:52 pm
Re: Setting focus to opened PDF document
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Tracker Software Products (Canada) LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com