You are able to swap out the standard viewer menus with custom menus if you work a bit. Goodness.
When the viewer is about to display a menu or it just displayed one, you can get its specific name using "Notifications.ContextMenu.MenuName". This is great.
When I'm in a Form Field and right mouse click, I get "TextEditor" returned. Makes sense since I'm editing text.
When I'm in a Popup Note and am editing text, I get "TextEditor" as well. Still makes sense.
When I'm in a Typewriter tool or Text Note tool, I still get "TextEditor". And yet it still makes sense.
How can I distinguish between the different contexts though? I need a different menu for Form Fields than I do for the rest. The main Viewer program distinguishes so how can I?
I've searched the forums and believe that there is no way in this release to determine the active element (annotation, form field, etc.). Based upon that, I've thought about querying the viewer if specific commands are enabled. The thought being if I can find one or more commands that are enabled or disabled I can rule out annotations as compared to form fields. For example, if "Add Reply" is enabled then I'm not in a form field. Problem is that I could be in a Text Note or Typewriter annotation and they don't have "Add Reply" If the PDF has not Form Fields then I'm in an annotation. Problem is, it could have both or just annotations or just form fields.
I've also noted that when adding a new Typewriter or Note Tool and Right Mouse Clicking __before__ clicking elsewhere in the viewer that Ordering (send back/forward) are disabled. They become enabled once I cease Text Edit mode and then go back into it. If that worked as soon as the annotation was dropped on the canvas, I would be set but I'm guessing that the annotation has not fully been created yet.
Any great ideas how to determine if a Form Field is active during a context menu activation? How is the main viewer doing it?
By the way, when is 3.0 due out? I can cripple my product in some areas knowing I can use 3.0 in a future release.
When the TextEdit menu is displayed...
Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
-
- User
- Posts: 216
- Joined: Thu Jul 08, 2004 7:29 pm
-
- Site Admin
- Posts: 2448
- Joined: Thu Jun 30, 2005 4:11 pm
Re: When the TextEdit menu is displayed...
Hi, DSSavant.
To detect focused form field:
- also you may use GetSelectedWidget operation.
Look to SDK help for details.
HTH
You may use next method to detect type of focused annotation (non-field):When I'm in a Form Field and right mouse click, I get "TextEditor" returned. Makes sense since I'm editing text.
When I'm in a Popup Note and am editing text, I get "TextEditor" as well. Still makes sense.
When I'm in a Typewriter tool or Text Note tool, I still get "TextEditor". And yet it still makes sense.
How can I distinguish between the different contexts though? I need a different menu for Form Fields than I do for the rest. The main Viewer program distinguishes so how can I?
Code: Select all
ctrl.DoDocumentVerb(docID, NULL, "GetSelectedAnnot", NULL, out DataOut, 0);
int pageIndex = DataOut[0];
int indexOnPage = -1;
if (pageIndex >= 0) // we have selected (focused) annotation (non-field)
{
indexOnPage = DataOut[1];
...
}
if (indexOnPage >= 0)
{
string js;
js = "var a = this.getAnnots("+ pageIndex+"); if (a.length > "+indexOnPage+") { a["+indexOnPage+"].type; }"
string res;
ctrl.RunJavaScript(js, out res...);
}
...
Code: Select all
ctrl.DoDocumentVerb(docID, NULL, "GetSelectedField", NULL, out DataOut, 0);
string fieldName = DataOut;
...
Look to SDK help for details.
HTH
PDF-XChange Co. LTD (Project Developer)
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 216
- Joined: Thu Jul 08, 2004 7:29 pm
Re: When the TextEdit menu is displayed...
My SDK PDF is dated 9/10/2010. I'll assume the documentation is in the latest build's SDK and will update today. Thanks, these will be very useful.
-
- Site Admin
- Posts: 19913
- Joined: Mon Jan 12, 2009 8:07 am
Re: When the TextEdit menu is displayed...
Hi DSSAvant,
Yes please do update, and let us know how the suggestions Vasyl gave worked out
Cheers,
Stefan
Yes please do update, and let us know how the suggestions Vasyl gave worked out

Cheers,
Stefan