[Lars H], 4 May 2007: I have a program displaying some diagrams in a [canvas] widget, and now I want to put some hyperlinks in that canvas as well. (These hyperlinks would basically cause a particular detail in the diagram to be displayed in greater detail, as there are many levels of abstraction in the data being displayed.) However, I find it rather difficult to get the proper behaviour in a canvas. As a long-time Mac user, I find it obvious that a hyperlink should behave as follows: 1. When the mouse pointer is on the hyperlink, it should change shape (typically to a pointing hand). 2. When the mouse button is pressed, the hyperlink should be highlighted. 3. Only if the mouse button is then released over the hyperlink will the action be triggered. I haven't found this spelt out specifically for hyperlinks anywhere (though I haven't searched much either), but it can be deduced from general rules on how the mouse should behave [http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html], and it is also what I see in all browsers I've checked (both Web and non-Web). The catch is that this seems rather hard to implement in Tk. What I think should work is to do the following: * Every hyperlink is an embedded window item, probably a [label]. This is necessary since the only mechanism Tk provides for changing the cursor is the window option -cursor. * The highlighting is done by explicitly changing colour on the item (-foreground, -background, or both). * Explicit bindings are needed for highlighting on (ButtonPress) and highlighting off (Leave). This feels very roundabout (even though it is still probably easier than most C APIs would be), probably too complicated for the rather specialised program that it would be in. What made me curious is that I noticed that a slightly different behaviour is much easier to support under Tk: 1. When the mouse pointer is on the hyperlink, the hyperlink should be highlighted (-activeforeground or -activebackground). 2. When the mouse button is pressed, the action is taken. All of this can be achieved with ordinary text items in the canvas, since these support both bindings and the fancy -active... options. First time I ever saw any use for them, but then most things in Tk seem to have dozens of options I've never used... Still, this seems almost too good a fit to be accidental. Perhaps some knowledgable person could tell me if the second behaviour is what one finds in [X], as in that case this would be yet another way in which Tk is showing its deep [X] roots, despite aiming to be a cross-platform GUI toolkit. ---- [[ [Category GUI] | [Category Platform Issues]? ]]