bobbylight / RSyntaxTextArea

A syntax highlighting, code folding text editor for Java Swing applications.
BSD 3-Clause "New" or "Revised" License
1.1k stars 256 forks source link

Wait for a hyperlink to be activated before processing it #394

Open DeflatedPickle opened 3 years ago

DeflatedPickle commented 3 years ago

I wanted to achieve a similar effect to an IDE's navigation via code bits (hold ctrl and click on a function to go to the definition). This lead me to find LinkGenerator and LinkGeneratorResult, both of which I've extended and have working nicely

My problem is that to activate my hyperlink, all one has to do is hold ctrl. I would like for it to require a right-click as well, as the sudden jump is a little confusing

This doesn't seem to be possible to check from my side as the LinkGeneratorResult#execute method has no context for the mouse and on this line, it will only send ENTERED and EXITED events based on the cursor

My class extending from LinkGeneratorResult has it's execute method fired immediately after hovering over the token I want it to, however I don't think I can insert some way to require the mouse be clicked before furthering that, unless I use a 3rd-party raw mouse library, so I thought about making my HyperlinkListener more than a stub (is it supposed to be required to have one for links to work at all?), and I can have it send an event where the link is activated, but this is still sent from a hover event, so it works the same

It would be helpful if in LinkGeneratorResult, a mouse event could be passed in so I can check for clicks, or if some code was reworked to have click-able links more of a thing by having a property on RSyntaxTextArea for linkActivationType (I can look into this if that'd be helpful)

omegaui commented 3 years ago

Hi!

Take a look at src/omega/instant/support/java/JavaCodeNavigator.java

On this repo

omegaide

bobbylight commented 3 years ago

Pull requests are welcome for this one! I'll take a look but this is lower priority than other items at the moment.