How can I detect which Tooltype is seleted?

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

How can I detect which Tooltype is seleted?

Post by Dorwol »

Hi,

please how can I detect which Tooltype (like rectangle, box, Line, Handtool) is actually seleted?
User avatar
Paul - PDF-XChange
Site Admin
Posts: 7372
Joined: Wed Mar 25, 2009 10:37 pm

Re: How can I detect which Tooltype is seleted?

Post by Paul - PDF-XChange »

HI Dorwol,
whan you select a tool the icon will show up slightly differently to when it is not. You can hit the "Keep tool Selected" button to make sure it stays selected but selected tools should look like a pushed button compared to those not selected.

see attached screenshot. In this example the 'Rectangle Tool' is selected.
You do not have the required permissions to view the files attached to this post.
Best regards

Paul O'Rorke
PDF-XChange Support
http://www.pdf-xchange.com
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: How can I detect which Tooltype is seleted?

Post by Dorwol »

THX, but you dont understand me.

I mean "BY CODE"!

So how can I identify which tool is activated - by Code?
ugradedeveloper
User
Posts: 223
Joined: Wed Aug 22, 2007 4:40 pm

Re: How can I detect which Tooltype is seleted?

Post by ugradedeveloper »

You need to get the value of "Tools.Active". See sections 2.2.2.13 and 2.2.3.38 in the documentation of the latest build.
User avatar
Chris - PDF-XChange
Site Admin
Posts: 798
Joined: Tue Apr 14, 2009 11:33 pm

Re: How can I detect which Tooltype is seleted?

Post by Chris - PDF-XChange »

Thx ugradedeveloper :)
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.


Chris Attrell
Tracker Sales & Support North America
http://www.tracker-software.com
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: How can I detect which Tooltype is seleted?

Post by Dorwol »

Perfect! :P
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: How can I detect which Tooltype is seleted?

Post by Dorwol »

Sorry for one question more, but I want to change some properties of a selected object in my PDF. But I don't know how... :(

For example, if I want to change the "FColor" of a seleted "Line" object. If "LineTool" is my active Tool, this is no problem (SetProperty "...Styles..."].FColor ...). But how can I change a the properties of a selected object, if the HandTool is still my active Tool?

So how can I detect, which object-Type (not ActiveTool !!!) is selected in my PDF? I need the information, if the selected object is a Line, Rectangle, Oval and so on... :?:
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: How can I detect which Tooltype is seleted?

Post by Corwin - Tracker Sup »

For now there is no way to detect which object is selected in PDF document.
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: How can I detect which Tooltype is seleted?

Post by Dorwol »

:(

OK, that's sad. But how can I change a property of a seleted (unknown) object by code?

For example I want to change the "SColor" of a selected object.

This will not work, because it chages only the default-color (of a Line-object):

Code: Select all

SetProperty "Commenting.Line.Styles[...].SColor", vDataIn
Please how can I do this with VB6 ?
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: How can I detect which Tooltype is seleted?

Post by Vasyl - PDF-XChange »

Dorwol wrote: ...how can I change a property of a seleted (unknown) object by code?
What means " seleted (unknown) object"? It is about annotation-object on the page?
You wanted to change properties of focused annotation? or to change current tool style?
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.
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: How can I detect which Tooltype is seleted?

Post by Dorwol »

Vasyl-Tracker Dev Team wrote: What means " seleted (unknown) object"? It is about annotation-object on the page?
You wanted to change properties of focused annotation? or to change current tool style?
Sorry for my bad english!
With "Unknown" I mean only, that my Code don't know (because can't detect!) the object-type.

And yes, I want to change properties of focused annotation. :!:
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: How can I detect which Tooltype is seleted?

Post by Corwin - Tracker Sup »

For now you cannot do this because when Viewer AX lost focus (for example when you click on your controls) it also deselects focused annotation. In new build we will try to change this behaviour, so you can use "this.selectedAnnots;" JS method.
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: How can I detect which Tooltype is seleted?

Post by Dorwol »

Corwin - Tracker Sup wrote:For now you cannot do this because when Viewer AX lost focus (...) it also deselects focused annotation.
Not for me. My application will works well (no deselecting by click on any Command-Button-Click of my appliactions own toolbar!).

So if there is a way to do this, I'm already happy. But if not, when do you think is the release-date of the new build? This month?

Thank you
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: How can I detect which Tooltype is seleted?

Post by Corwin - Tracker Sup »

The Standard Window toolbars doesn’t take focus from the Viewer control, so if you are using only the toolbar buttons, you can try to detect what annotation is selected by using the following JS code:

Code: Select all

var aAnnots = this.selectedAnnots;
if (aAnnots.length>0)
aAnnots[0].type;
HTH
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: How can I detect which Tooltype is seleted?

Post by Dorwol »

OK, good! But now...

...how can I change a property (like Color or Border) of a already seleted CommentTool-object by code?

For Example the user select a Line in his PDF and click on green-color-button in my toolbar (Line in PDF is still selected!). How can I set this to green?

Hope this is possible... :|
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: How can I detect which Tooltype is seleted?

Post by Vasyl - PDF-XChange »

Code: Select all

var annots = this.selectedAnnots;
if (annots.length > 0)
{
   annots[0].width = 10; // border width
   annots[0].fillColor = color.green;
   annots[0].strokeColor = color.green;
};
for details look in the ActiveX SDK Help (Reference->JavaScript Support->Annotation).
And also upgrade your distributive to version 42.4 prior to testing.
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.
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: How can I detect which Tooltype is seleted?

Post by Dorwol »

If I use this Code, Undo and Redo does not work :( :?:

Is this a bug or do I must call a Java-command like "AddUndoAction" or something else?

BTW: Because I develop normaly only in VB, allow me a question for a better understanding JavaScript-Actions in your Viewer-Control, will this always work? I mean does it also work if the user has no java-Engine in Windows installed or if the user has JavaScript disabled in your Preferences?

Is it planned to do the same by VB-Code (in next build or so...)?
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: How can I detect which Tooltype is seleted?

Post by Vasyl - PDF-XChange »

Because the many of edit-operation by JavaScript cannot be undone in current realization.
We will to add full undo-support to JS in the future.

Also we planning to add new edit-features without JS(but with full undo/redo) like as:
SetDocumentProperty(docId, "Selection[0].FColor", "red", 0);
SetDocumentProperty(docId, "Selection[0].SColor", "green", 0);
...
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.
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2448
Joined: Thu Jun 30, 2005 4:11 pm

Re: How can I detect which Tooltype is seleted?

Post by Vasyl - PDF-XChange »

it also work if the user has no java-Engine in Windows installed or if the user has JavaScript disabled in your Preferences?
Please do not confuse/mix the terminology - Java and JavaScript - these are two different technologies.

To support JavaScript, The Viewer does not require any additional products - everything required is already built-in.

And yes, it works when JavaScript execution is disabled by the user in the Preferences.
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.
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: How can I detect which Tooltype is seleted?

Post by Dorwol »

BIG THX 4 feedback!
Vasyl-Tracker Dev Team wrote:Also we planning to add new edit-features without JS(but with full undo/redo) like as:
SetDocumentProperty(docId, "Selection[0].FColor", "red", 0);
SetDocumentProperty(docId, "Selection[0].SColor", "green", 0);
...
Oh, that sounds realy good. But I think, this new edit-features will not implemented before december, OR? :?:
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: How can I detect which Tooltype is seleted?

Post by John - Tracker Supp »

We cannot be more specific at this time I am afraid.

Thanks for your patience.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com