Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programmatically select text #329

Closed
ostfale opened this issue Jun 20, 2016 · 3 comments
Closed

Programmatically select text #329

ostfale opened this issue Jun 20, 2016 · 3 comments

Comments

@ostfale
Copy link

ostfale commented Jun 20, 2016

I have some formatted text which consists of variables at fixed position. I can select the variables (combobox) and want to show (select) them in the text. I can jump to the right line / column. But if I call selectRange it highlights text in the first line.

Thx for help, regards, Uwe

@TomasMikula
Copy link
Member

Hi, selectRange expects absolute positions. Are you calling it with absolute positions?

If you have

int startRow;
int startCol;
int endRow;
int endCol;

you can convert them to absolute positions like this:

int startPos = area.position(startRow, startCol).toOffset();
int endPos = area.position(endRow, endCol).toOffset();
area.selectRange(startPos, endPos);

@ostfale
Copy link
Author

ostfale commented Jun 21, 2016

That's exactly the solution! Thanks...

@TomasMikula
Copy link
Member

There are now convenience methods taking row/col coordinates in the snapshot release thanks to @JordanMartinez via #331.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants