#1562 Clickable area of hotspots is off by half a character width


The clickable area of a hotspot is offset to the left by half a character width. For usual hotspots like links in hypertext (long string of narrow characters), this is hardly noticeable, but in my case my hotspots consist of a single character that is displayed as a relatively wide character representation. Having clicks on the right half of the representation ignored, or, worse, go to the next hotspot to the right if one is immediately adjacent, is quite irritating in this case.

This is because when determining whether the mouse is inside a hotspot, the mouse position is first rounded to the closest position between characters, as if to place the caret, and then the hotspotness of the character to the right of that position is checked. The attached patch fixes this to instead always consider the character on which the mouse is.

Steps to reproduce:
1. Build SciTE with the following patch applied:

diff -r 8ca6b7af8c10 -r 405886f36c75 src/Credits.cxx
--- a/src/Credits.cxx   Fri Dec 06 08:50:05 2013 +1100
+++ b/src/Credits.cxx   Tue Dec 10 12:27:20 2013 +0100
@@ -411,6 +411,12 @@
        SetAboutStyle(wsci, 1, ColourRGB(0, 0, 0));
        int trsSty = 5; // define the stylenumber to assign font for translators.
        SString translator = GetTranslationToAbout("TranslationCredit", false);
+       wsci.Send(SCI_STYLESETHOTSPOT, 7, 1);
+       wsci.Send(SCI_STYLESETHOTSPOT, 8, 1);
+       wsci.Send(SCI_SETREPRESENTATION, (uptr_t)(char*)"X", (sptr_t)(char*)"Representation X");
+       wsci.Send(SCI_SETREPRESENTATION, (uptr_t)(char*)"Y", (sptr_t)(char*)"Representation Y");
+       AddStyledText(wsci, "X", 7);
+       AddStyledText(wsci, "Y", 8);
        SetAboutStyle(wsci, trsSty, ColourRGB(0, 0, 0));
        AddStyledText(wsci, GetTranslationToAbout("Version").c_str(), trsSty);
        AddStyledText(wsci, " " VERSION_SCITE "\n", 1);
  1. Run SciTE, choose Help > About SciTE and mouse over the two blobs “Representation X” and “Representation Y” on the second line.

Actual result: When the mouse is over the right half of “Representation X”, “Representation Y” is underlined (and would receive a click if an event handler for it had been defined). When the mouse is over the right half of “Representation Y”, nothing is underlined (and no hotspot receives clicks).

Expected result: Exactly the hotspot under the mouse should be underlined and receive clicks.

1 Attachments


  • Neil Hodgson

    Neil Hodgson - 2013-12-13
    • labels: --> scintilla, hotspot
    • status: open --> open-fixed
    • assigned_to: Neil Hodgson
  • Christian Walther


    This appears to be a copy-paste error in [a8c29a]:

    diff -r 37a6d2fcac8a doc/ScintillaHistory.html
    --- a/doc/ScintillaHistory.html Sun Dec 15 12:49:06 2013 +1100
    +++ b/doc/ScintillaHistory.html Mon Dec 16 09:11:45 2013 +0100
    @@ -459,7 +459,7 @@
        Fix hotspot clicking where area was off by half a character width.
    -   <a href="http://sourceforge.net/p/scintilla/bugs/1553/">Bug #1553</a>.
    +   <a href="http://sourceforge.net/p/scintilla/bugs/1562/">Bug #1562</a>.


    Commit: [a8c29a]

    • Neil Hodgson

      Neil Hodgson - 2013-12-16

      OK, fixed.

  • Neil Hodgson

    Neil Hodgson - 2014-01-27
    • status: open-fixed --> closed-fixed

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks