Skip to main content

Posts

Showing posts from 2018

InDesign Scripting with ScriptUI: Add a TestIt Button to Play Around

Based on my previous article " InDesign Scripting with ScriptUI: How to Move Cursor and Select Text ", let's add a button to play around. The original code looks like this: // --- Last Part of UI (No Panel) --------------------------------------------- function AddCloseButton(w) { w.grpButtons = w.add('group'); w.btnClose = w.grpButtons.add('button {text: "Close"}'); w.btnClose.onClick = function () { w.close(); } } // ------------------------------------------------------- Let me add a button to select a piece of text. Below in in the listener function "TestIt", I don't add the boundary checking . You may try and modify the variables "start" and "end" to go over the boundary. And see what happens. // --- Last Part of UI (No Panel) --------------------------------------------- function AddCloseButton(w) { w.grpButtons = w.add('group'); w.grpButtons.orientation = "column"; ...

InDesign Scripting with ScriptUI: How to Move Cursor and Select Text

Based on the code pattern in my  previous article , here I’d like to show the methods to move the cursor and to select text with button click on ScriptUI. Using buttons to move cursor and to select text is useful when working with a script, which has a UI. You don’t need to move your mouse running all over the whole screen very often for doing your tasks. Most of the time, you can concentrate your mouse movement just around the UI of your script. The code is divided into 4 parts: Part 1 , from line 10 to line 28: This is the coding pattern for the modeless dialog. Part 2 , from line 37 to line 57: The main UI is created in this part. Part 3 , three groups of buttons are created here, together with the functions, which are attached to the button click event. Group 1: from line 60 to line 67, the code setups the buttons for moving cursor. from line 69 to line 118, the event listener "MoveCursor" is defined. Group 2: from line 121 to line 128, the code s...