These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to get part name on mouse click

manasa
manasa's picture
Registered: Jun 30 2011
Posts: 16
Answered

Hi,
 
I have a 3D model. When I click on the part it gets selected with different render mode. I want to get the name of the part from model tree as an alert...
 
Like... "You have clicked on 'BASE_$4' "
It should get on button click. It must give a popup as soon as i click on the part

My Product Information:
Acrobat Pro Extended 9.0, Windows
UVSAR
UVSAR's picture
Expert
Registered: Oct 29 2008
Posts: 1357
Accepted Answer
You'll have to do that using a block of embedded 3D Javascript - it's possible but only if the part is clicked on within the 3D viewport rather than selected on the model tree.

Paste the following into a new text file, save with a .js extension, and load it into the Script field on your 3D annotation's Properties>3D tab.
.
.
.
// script begins on the line below this

runtime.overrideSelection = true;

var myMouseHandler = function( event ) {
if ( event.isMouseUp ) {
var myMesh = null;
if ( event.hits.length > 0 ) myMesh = event.hits[0].target;
if ( myMesh != null ) {
host.app.alert("You clicked on " + myMesh.name);
}
}
}

var mouseEventHandler = new MouseEventHandler();
mouseEventHandler.onMouseDown = false;
mouseEventHandler.onMouseMove = false;
mouseEventHandler.onMouseUp = true;
mouseEventHandler.onEvent = myMouseHandler;
runtime.addEventHandler( mouseEventHandler );

//end of script
manasa
manasa's picture
Registered: Jun 30 2011
Posts: 16
Thank you so much
its working.
Now can I get the name from alert to a TextBox using C#?
manasa
manasa's picture
Registered: Jun 30 2011
Posts: 16
Hi UVSAR,

Thank you so much once again...
Its working great...
But how can I display the name in an text box of web application using C#?
I have done same using Electronic Forms in PDF...
Please let me know how I can display the name from alert message to a text box in browser?
manasa
manasa's picture
Registered: Jun 30 2011
Posts: 16
manasa wrote:
Hi UVSAR,Thank you so much once again...
Its working great...
But how can I display the name in an text box of web application using C#?
I have done same using Electronic Forms in PDF...
Please let me know how I can display the name from alert message to a text box in browser?
UVSAR
UVSAR's picture
Expert
Registered: Oct 29 2008
Posts: 1357
How are you communicating with your application? The Acrobat SDK does not support C#, only C++.
manasa
manasa's picture
Registered: Jun 30 2011
Posts: 16
I will be using VB.NET to open the PDF in browser
And have embedded JS to 3D model which gives part name as alert on click ...
Now tell me how can I get that name into VB textbox of browser???
manasa
manasa's picture
Registered: Jun 30 2011
Posts: 16
hey small mistake
I will be using VB.net to open PDF through Windows application...
but i want the name of part from alert to text box...
or diretly in the text box as soon as i click on the part
manasa
manasa's picture
Registered: Jun 30 2011
Posts: 16
Hi UVSAR,

Can u please tell me how to get the control of javascript into my dot net application?
I have been waiting for sooo long ...
its really very important.

manasa
manasa's picture
Registered: Jun 30 2011
Posts: 16
manasa wrote:
manasa wrote:
Hi UVSAR,Thank you so much once again...
Its working great...
But how can I display the name in an text box of web application using C#?
I have done same using Electronic Forms in PDF...
Please let me know how I can display the name from alert message to a text box in browser?
UVSAR
UVSAR's picture
Expert
Registered: Oct 29 2008
Posts: 1357
You can create a link to the JavaScript engine "root object" from your IAC code by declaring an instance of pdDoc.GetJSObject() once you've opened the file and linked to the pdDoc() object. The properties of JSObject are the properties of the JavaScript engine, so you can invoke member functions on it:


Object jsObj = pdDoc.GetJSObject();
Type T = jsObj.GetType();

String newFileName = "myfile.pdf";
object[] saveAsParam = { newFileName };
T.InvokeMember("saveAs",BindingFlags.InvokeMethod | BindingFlags.Public |
BindingFlags.Instance, null, newDoc, saveAsParam);

double nPages = (double)T.InvokeMember("numPages", BindingFlags.GetProperty |
BindingFlags.Public | BindingFlags.Instance, null, jsObj, null);



manasa wrote:
Hi UVSAR,
Can u please tell me how to get the control of javascript into my dot net application?

manasa
manasa's picture
Registered: Jun 30 2011
Posts: 16
hi
so that can i get the part name in the text box of web application/ windows application???

manasa
manasa's picture
Registered: Jun 30 2011
Posts: 16
manasa wrote:
hi
so that can i get the part name in the text box of web application/ windows application???
manasa
manasa's picture
Registered: Jun 30 2011
Posts: 16
But how can I display the name in an text box of web application using C#?
I have done same using Electronic Forms in PDF...
Please let me know how I can display the name from alert message to a text box in browser?
UVSAR
UVSAR's picture
Expert
Registered: Oct 29 2008
Posts: 1357
We don't generally provide detailed support on these forums for people using IAC, as without seeing the external code it becomes a complex and time-consuming process to steer a novice user through a case-specific workflow. Handling events in the host that are fired from within the PDF's JavaScript object is not something the IAC was designed to do - it's primarily a system for controlling the PDF viewer instance, not for listening to it.

For specific questions on the IAC methods and properties exposed by Acrobat and Adobe Reader you're best to post your question in the Acrobat SDK Forum.
manasa
manasa's picture
Registered: Jun 30 2011
Posts: 16
thank you