Skip to main content
Participating Frequently
May 8, 2019
Answered

searching content of multi line Text Field

  • May 8, 2019
  • 2 replies
  • 571 views

Hello

i have a large multi line Text Field that contain multiple visits with a certain Date configurations

something like this (Sunday 06/01/2019):

I was able to collect them through RegEx and put them in a popUpMenu through this code:

function ShowVisits() {

var keyword = /[(](\w{6,9})\s(\d{1,2})[/](\d{1,2})[/](\d{4})[)][:]/g

var str = this.getField("HistoryT").value;

var match = str.match(keyword);

var begining = ["Visits"];

var aGhazali = match.unshift(begining)

var cRtn = app.popUpMenu(match)

}

What I would like to do now is to modify the function to search in the content of the Text Field  and do something like setting focus or scroll down to where the match is.

I have tried to search using the built in Find but it only finds the match if it is available in the screen, but if its need to be scrolled to find will show no matching is found

thanks

This topic has been closed for replies.
Correct answer try67

That is not possible.

2 replies

Thom Parker
Community Expert
Community Expert
May 8, 2019

There is no straight forward way to do this.  The only way to select text within a text field is through the Keystroke event.  And I do now know if this would result in the text field scrolling to a specific position. But you could try. Unfortunately there is only way to get an uncommitted keystroke event, and that is for the user to click into the text field. So you'd have to first select from the dropdown, and then click into the text field.

Look up the event.selStart and event.selEnd properties of the Event object.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
May 8, 2019

That is not possible.