home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!sunic!chalmers.se!etek.chalmers.se!fy.chalmers.se!jacob
- From: jacob@fy.chalmers.se (Jacob Hallen)
- Newsgroups: comp.lang.tcl
- Subject: Possible tk bug and some questions
- Message-ID: <1992Nov16.055950.1700@fy.chalmers.se>
- Date: 16 Nov 92 05:59:50 GMT
- Sender: jacob@fy.chalmers.se
- Organization: Chalmers University of Technology, G|teborg, Sweden
- Lines: 65
-
- QUESTIONS
-
- - Is it possible to warp the mouse pointer from inside tk?
- - Is it possible to have one binding of an event (<1> for instance) in the
- canvas in general, and a different binding of the same event inside
- an item of the canvas?
-
-
- POSSIBLE TK BUG
-
- The code below does the following:
- - Create a rectangle inside the canvas
- - Read a string to put in the middle of the rectangle. This is done by
- creating a window with an Ok button and an entry box.
- - Bind events to the rectangle and the text
-
- The problem is this:
- If I have the outcommented grabs in place, I need tp press a mouse
- button before I get the Any-events in my canvas. Is this as it should be?
-
- ************************************************************************
- proc scrollNmread { nm } {
- global xName;
- set xName ["$nm.entry" get]
- }
- proc scrollMkname {{ nm .nameentry }} {
- global xName;
- set xName "";
- toplevel $nm;
- entry $nm.entry -state normal -width 20 -relief sunken
- button $nm.bt -text Ok\
- -command "scrollNmread $nm";
- bind $nm.entry <Key-Return> "scrollNmread $nm";
- pack append $nm $nm.entry {top expand} $nm.bt {bottom filly}
- # grab $nm;
- set a [focus]
- focus $nm.entry;
- tkwait variable xName;
- # grab none;
- focus $a;
- destroy $nm;
- return $xName
- }
-
- proc scrollMkroom {canvas x y} {
- set bg pink2;
- set x [$canvas canvasx $x];
- set y [$canvas canvasy $y];
- set id [ $canvas create rect [expr $x-40] [expr $y-20]\
- [expr $x+40] [expr $y+20] -outline black -fill $bg -tags rect ];
- set id2 [$canvas create text $x $y -text [scrollMkname] \
- -anchor center -tags text];
-
- $canvas bind $id <Any-Enter> "scrollEnter $canvas";
- $canvas bind $id <Any-Leave> "scrollLeave $canvas";
- $canvas bind $id <Double-1> "scrollButton $canvas";
- $canvas bind $id <1> "scrollStartDrag $canvas %x %y";
- $canvas bind $id <B1-Motion> "scrollDrag $canvas %x %y";
-
- $canvas bind $id2 <Any-Enter> "scrollEnter $canvas";
- $canvas bind $id2 <Any-Leave> "scrollLeave $canvas";
- $canvas bind $id2 <Double-1> "scrollButton $canvas";
- $canvas bind $id2 <1> "scrollStartDrag $canvas %x %y";
- $canvas bind $id2 <B1-Motion> "scrollDrag $canvas %x %y";
- }
-