DriveWorks

All the Applications, Scripts, Plug-ins, and Add-Ons listed here are completely FREE to use or modify as covered under the:

PolyForm Noncommercial License 1.0.0

Contact me at for a commercial license.

If you have an idea or specific request for a new DriveWorks (DW), SolidWorks (SW), EspritCAM Add-in, Rhino Script/Addin/Plug-in or any other sort of automatization, do not hesitate to contact me at the email listed at the bottom of the page.

How to get cursor/caret position inside DW' textbox (DW18 - Integration Theme)

It is all about the JavaScript! A form designed inside the DriveWorks at the end, at the time of use, is converted/rendered to/as HTML!

The main question is: How to find our DW' TextBox and DW' Label (<-an element where to display the cursor position)? After finding the HTML element of interrest, we need to implement/add EventListerners (keyup, click ..) to the found HTML object to get results on a status change.
Once converted, all the HTML elements, are "under" DIV control! They do NOT have unique IDs assigned but luckily there are DEVs unique names attribute! So, we will use that to start our GetCursorPosition implementation:
Create a new JavaScript file and put all the below code into it:  i.e. DWCursorPosition.js

// global
let
 myInputTextBox;
let
 myInputLabelDiv;

// let's find our DW HTML elements
function
 GetCursorHTMLElements() 
{
    let myDivByNameExport;
    let
 myDivByNameLabel;

    
myDivByNameExport = document.getElementsByName("name of your DW textbox"); // we got our DIV container of the textbox
    
myInputTextBox = myDivByNameExport[0].getElementsByTagName("Input")// drill down to get the input textbox

    
myDivByNameLabel= document.getElementsByName("name of your DW label");// get label where to output results
    
myInputLabelDiv = myDivByNameLabel[0].getElementsByTagName("DIV")// label element is nested one node down, so we need to drill a bit more

// add event listener to our HTML DIV.TEXTBOX object onclick and onkeyup
    
if (myDivByNameExport[0].addEventListener) {
        
myDivByNameExport[0].addEventListener("click",GetCursorPosition,false);
        
myDivByNameExport[0].addEventListener("keyup",GetCursorPosition,false);
    }
}


// get textbox caret postion

function
 GetCursorPosition (){
     
var startPosition = myInputTextBox[0].selectionStart;
     
var endPosition = myInputTextBox[0].selectionEnd;
    
// Check if we have selected text
     
if(startPosition == endPosition){ /*not selected*/
            
myInputLabelDiv[0].innerHTML = startPosition; 
    }

//else = selected to be implemented if needed// do not have use for it now so skip it
}


For the Integration Theme I've placed GetCursorHTMLElements call inside the setNavigationState (run.js) function call that asynchronously is looking into display changes. The GetCursorHTMLElements needs to be executed only once after form is loaded! In my case and for variety of reasons I needed it on the form change.

// get DW HTML elements
async
 function setNavigationState(formData)
{
   
GetCursorHTMLElements();
}


Add DWCursorPostion.js at the end of script section inside the run.html:

// javascript
<script src="dist/js/core.js"></script>
<
script src="dist/js/run.js"></script>
<
script src="dist/js/DWCursorPosition.js"></script>



Likely, the workflow is similar for the Web Theme!?

Now that we have cursor position we could go visual with a tooltip!    cursor_tooltip




Downloads

 

 


 

 



C# / C++ / VB / CAD / CAM / Esprit / Rhino3D / SQL / SOLIDWORKS /DriveWorks / SolidEdge programming & 3D Solid Design

 
To contact me, I am available through the below listed e-mail address. If you are interested in any of the above, just drop me an email and I can make what needs to be done.

e-mail:   








keywords: on line on-line online esprit esprit CAM nesting E-Nesting.com 2D vector web software asp on line optimization layout xml shoe glass sheet metal free placing cutting strategy case before waste dot .net minimal waste algorithm industry yield material cost save reduce true nesting IGS IGES interactive automatic true rhino3d rhino CAD CAM DXF DWG 3DM convert free layout algorithm shear nest true browser industry on line on-line online nesting E-Nesting.com 2D vector web software asp optimization layout xml shoe glass sheet metal free placing cutting strategy case before waste dot .net minimal waste algorithm industry yield material cost save reduce true nesting IGS IGES interactive automatic true rhino3d rhino CAD CAM DXF DWG 3DM convert free layout algorithm shear nest true browser industry on line nesting on-line nesting online nesting "on line nesting" "on-line nesting" "online nesting" nesting software linear nesting rectangular nesting nesting optimization sheet nesting length nesting automatic nesting nesting part nesting on line on-line online E-Nesting.com 2D vector web software asp optimization layout xml shoe glass sheet metal free placing cutting strategy case before waste dot .net minimal waste algorithm industry yield material cost save reduce true nesting IGS IGES interactive automatic true rhino3d rhino CAD CAM DXF DWG 3DM convert free layout algorithm shear nest true browser industry convert dwg dgn convert dwg to dgn plant layout solidworks cam dwg viewer layout software dwg java viewer cad drawing cad drawing software cad drawing services cad drawing viewer cad drawing programs electrical cad drawing auto cad freeware auto cad auto cad software auto cad viewer auto cad courses cad cutting cad dxf rhino cad cad dwg rhino cad software cad freeware cad viewer freeware cad solidworks cad autocad freeware ad software cad viewer software cad cae cad viewer cad cad software cad linux medusa cad cad file viewer cad reader graphite cad cad library cad design cad interoperability cad translators cad translator ring cad cad sales cad equipment cad pdf cutting optimizer cutting diagram cutting software automatic cutting cutting edge cutting edge solutions metal cutting sheet metal cutting cardboard cutting dwg dxf viewer dxf file viewer dxf freeware open source dxf dxf convert to dxf convert convert dxf to pdf dxf mac java dxf dxf pdf cad cam cad cam freeware cad cam software cad cam solutions unigraphics cad cam cad cam cae cad cam companies auto cad cam dolphin cad cam cad cam jewellery cad cam jewelry cad cam pictures cad cam pdf sheet metal cad cam