Menu

#14 Support for ctrl/meta key to have handle cursor over links and to open links

Unstable_(example)
open
nobody
None
8
2014-11-30
2014-11-22
No

Hi. I added few listeners to be able to open links in browser using ctrl/meta key. It's a bit flickering, but works for my needs, so maybe it could be useful for someone else as well.

https://github.com/xbup/xbup-java/blob/1990be5e2013df25e5a03f6118a6d6d26888f758/modules/simplyhtml/src/main/java/com/lightdev/app/shtm/DocumentPane.java

Discussion

  • Felix Natter

    Felix Natter - 2014-11-30

    hello Miroslav,

    thanks for contributing.

    I just tried your patch (DocumentPane.java changes), but I cannot see how
    clicking on hyperlinks in the editor pane works now. Can you elaborate?

    Also, would you be willing to fix bugs in your implementation
    (which is necessary for us to be able to include this in simplyhtml/freeplane)?

    Thanks and Best Regards,
    Felix

     
  • Miroslav Hajda

    Miroslav Hajda - 2014-11-30

    Hi Felix,
    I apologize, I sure should make it more clear, that I don't recommend this code to be included in the project itself, at least not as it is. More like as an additional feature for someone who might need something like that. What it do:

    • When CTRL key (META key on OS-X) is not pressed editor should behave normal way (the same as before)
    • When CTRL is pressed and hold, it attempts to detect, if tag under mouse cursor is anchor tag and then change mouse cursor shape to "hand"
    • When CTRL is pressed and hold and left mouse click is performed, if mouse is at the same time positioned above anchor tag, it will attempt to open this link using default runtime-set behavior for link opening

    Local or special links are not supported in this patch. I cannot promise to fix bugs, I'm willing to try, but my experiences with Java are somehow limited. For example fixing that small flickering I mentioned might require subclassing and overriding JEditorPane, in worst case even reintroducing modified copy of that class which might be a bit complicated think to do and I wanted to keep the patch as small as possible...

    Thanks for your reaction and keep up good work,
    Miroslav

     
  • Miroslav Hajda

    Miroslav Hajda - 2014-11-30

    I took a look on code again and found out, that there is actually hyperlink event handler I can register to use for CTRL+click, so I see what you meant, that it's no different. So then this patch might be only partly useful for mouse cursor shape changing then.

     

Log in to post a comment.