开发者

Mimicing Tcl/Tk's Font "OnMouseEnter" behavior in a C# application

开发者 https://www.devze.com 2023-02-23 18:55 出处:网络
I was looking at a program my friend sent me that was written in Tcl/Tk.It has a rich-formatting multi-line text box with different colors and fonts, and for certain blocks of text the application win

I was looking at a program my friend sent me that was written in Tcl/Tk. It has a rich-formatting multi-line text box with different colors and fonts, and for certain blocks of text the application window reacts to users hovering over different text elements. He says this is implemented by specifying a "OnMouseEnter" callback event when creating a new font. This seems like a cool and elegant approach, and I wanted to do something similar in a C# app I wrote. 开发者_JS百科 At the moment the three ways I can think to do this are: (a) work out the mapping from X-Y mouse coords to text (maybe there is an easy function for this?) (b) make each distinct text block a child control with its own callback functions (which is very ugly and would require me to do my own text wrapping) or (c) make it a webpage control and have javascript "call" C# via WebBrowser.Navigating. Any suggestions as to the best way to implement this kind of functionality would be welcome.


Most textbox control have X-Y coord to text block translation function calls. You can hook the entire mouse move event for the textbox and see what's beneath the mouse.

This might be ugly code but at least it would work.

0

精彩评论

暂无评论...
验证码 换一张
取 消