[Solved] Gutter Mouseclick Line

Questions on using RSyntaxTextArea should go here.

Moderator: robert

[Solved] Gutter Mouseclick Line

Postby LiquidBacon » Sat May 10, 2014 10:47 pm

I am able to receive mouse-events on the gutter. But is there a pretty way of knowing on which line segment was clicked?

PS: sorry if this was answered before; I didn't find anything helpful on this matter.
Last edited by LiquidBacon on Tue May 13, 2014 8:06 am, edited 1 time in total.
LiquidBacon
 
Posts: 4
Joined: Sat May 10, 2014 10:19 pm

Re: Gutter Mouseclick Line

Postby robert » Tue May 13, 2014 3:09 am

The Fold indicator in the gutter component uses this code; you should be able to do the same thing:

java code:

private int rowAtPoint(Point p) {

int line = 0;

try {
int offs = textArea.viewToModel(p);
if (offs>-1) {
line = textArea.getLineOfOffset(offs);
}
} catch (BadLocationException ble) {
ble.printStackTrace(); // Never happens
}

return line;

}


You can call this method on e.g. a mouseClicked() call to the gutter. If you'd like to see this method exposed for extensions to the gutter, please add a feature request on GitHub.
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm

Re: Gutter Mouseclick Line

Postby LiquidBacon » Tue May 13, 2014 8:06 am

Works great. Thank you, robert! =)
LiquidBacon
 
Posts: 4
Joined: Sat May 10, 2014 10:19 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 3 guests

cron