06-06-2020, 16:01 +0200
AuthorPost
GanianX11-28-2005, 09:54   | Mouse event Bindings, Sharing widget properties
(Guest)
Hello.
My name is Pedro Guillem, i work as a junior programmer for Bayes Forecast - Madrid - Spain.

We have an open source statistical analisys solution under developement. The core of the TOL (time oriented language) was built on C++, and we opted to use TCL/TK to build our GUI.
The maturity of the whole project is outstanding and we keep working to improove it. Feel free to get a copy from our CVS at http://www.tol-project.org .

We have created an editor window in order to enable users to code large programs using the GUI under TOL. It works fine, but, every decent IDE has the abbility to trace variable content and function parameters showing them as Hints at debug time, this is where my question comes in.

I started designing a way of implementing this into our editor the following way. First the editor code is to be compiled (this is already done).. all the variables and functions generated by the program are stored in memory, and finally shown beautifully on another window... (the editor works currently this way). When the code becomes larger than 5000 lines, going up to look at declared funcion parameters, or even searching for the value of a variable becomes impossible without visual aids from the GUI.

The only widgets cappable of generating the HINT property in tk are buttons, entries and some images. But our editor uses the TEXT widget to handle the coding. I have no idea how to blend the hint property to a line of text.

So i taught in the following:

1) Bind the <Motion> event to a procedure, sending the current mouse coordinates inside the text widget as args. (this works fine).

2) The procedure would analyze the text under the mouse pointer coordinates, get the string of text, and then do an intersection between the word and the set of existing variables and function names.

3) If the string returned matched any existing function or variable, the content of such variable would have to be show in the screen as a popup hint.

Problems:
1) The text editor screen is 800x800 pixels... if any change in the mouse position is to be evaluated by a procedure.. i'll kill the processor, that's for sure.

2) There are not known properties in the text widget to obtain a whole word from a mouse position, i had to create it, still, we find again the problem # 1.

3) In order to avoid constant evals of the mouse pointer coordinates, i'd need to bind a timed event.. if the mouse stands for 3 seconds over a word, then the process would execute... i don't know how to do this using bind. the other way would be to create the timer inside the procedure that evals the position, but then the editor would only work every 3 seconds... just crazy...

4) All of the above mentioned problems can be solved replacing the timer with a Key press event.. the mouse stops at a word and then the user presses the key... F10 to show the hint... easy enought... now comes the real question.

How can i bind the "hint" property to the text widget?. I'll be more clear, i have 5000 words inside a tk text window, each one of those words has a different value.  I want to display a HINT showing its definition when my mouse stops above one of them...

Most coders know what i'm talking about, if anybody has experience with timed events binding, or sharing properties among widgets in TCl TK.. PLEASE... i will appreciate some feedback!... anything will be accepted!

Thank you very much!

Keep it up Tcl enthusiasts!

Pedro
elven  12-03-2005, 20:38   Jabber
security dept.
(Administrator)
Member since 03/2004
55 Posts
Hi Pedro.

First off, i cannot help you with those bind problems, since i have never ever tried Tk, funnily enough. :)
However, i have got an idea concerning the keypress.

Your "timed" bind: bind for mouse movement and record the first coordinates - then discard all further bind events until a reasonable amount of time (200ms?) has passed. Do that either by unbinding and rebinding with "after" (again, never worked with Tk, so i do not know if that is possible) or an if-block that returns (whatever works best, performance-wise.
Then check again - if the coords have not changed and the cursor happens to be under some word with definition, show hint/popup.

Thats of course just a somewhat crude hack, but it is all i got to offer. I think it is more comfortable than pressing a key.

Regards

irc.swordcoast.net
Advanced options for this topic:

Ignore this topic (Do not list this topic in the "unread topics" search. You are currently not ignoring this topic.)
Hide this topic (Hidden topics are not displayed in the topics list. This topic is currently not hidden.)
Go to forum

Unclassified NewsBoard 1.5.3-d | © 2003-4 by Yves Goergen | Time: 157.5 msec, CPU time: 74.2 msec, 31 Database queries in 114.5 msec | 4.5 kB (13.5 kB) | Timezone: +0200