findAll() / findAllText() returns on one result

Asked by kai

Hi all,

I opened TextEdit, and typed in the following:
Test
Test
Jump
Jump and Run

Then, I use the following code to find the text "jump", expecting that it will return 2 results. But I only got one.
Here is the code (in Java)
     int count = 0;
     Iterator<Match> matches = App.focusedWindow().findAll("Jump") // or Test
     while(matches.hasNext()) {
         Match m = matches.next();
         m.highlight(2);
         ++count;
     }

Only the first Jump was highlighted (count = 1)

Is there a way for me to find the 2 "Jump"

Thanks,
kai

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

tested with 1.1.0:
apparently findAll() only returns 1 match.
I simply have to take this as bug, which will surely not be solved in the next weeks or even months, since problems with the text feature I will not touch earlier.
Sorry.

this at least found all <Jump> in my text:

      Debug.on(3);
      Settings.InfoLogs = false;
      Settings.ActionLogs = false;

      Settings.OcrTextSearch = true;
      Region eWin = App.start(App.Type.EDITOR);
      eWin.write("\n Jump\n\n Jump and Run\n\nRun and Jump\n");
      Region reg = eWin;
      while (true) {
        Match ms = reg.exists("Jump", 0);
        if (ms == null) {
          break;
        }
        ms.highlight(2);
        ms.x = eWin.x;
        ms.w = eWin.w;
        reg = eWin.intersection(ms.below());
      }

It seems, that the text search works from top left to bottom right.

Can you help with this problem?

Provide an answer of your own, or ask kai for more information if necessary.

To post a message you must log in.