Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Q: Sweep button events.

0 views
Skip to first unread message

Hubert Halkin

unread,
Jan 22, 1995, 8:32:06 PM1/22/95
to
The following tk script:

for { set i 0 } { $i < 5 } { incr i } {
label .$i -text $i
bind .$i <Shift-Enter> "puts $i"
pack .$i
}

produces a window such that

1. Just moving the pointer over the window produces nothing
2. Moving the pointer over the window WHILE the shift key is
down, prints to stdout the indices of the label visited.

Here is my question:

By what should I replace <Shift-Enter> in order to produce a window such that

1. Just moving the pointer over the window produces nothing
2. Moving the pointer over the window WHILE button 1 is
down, prints to stdout the indices of the label visited.

If this is not possible for button 1, what about button 2 or 3?

Your help will be greatly appreciated!


Hubert Halkin
Department of Mathematics
UCSD, La Jolla, CA 92093-0112 USA

mailto:hha...@ucsd.edu
phone: (619) 534-2622
www: http://bitmed.ucsd.edu/


Kevin B. Kenny

unread,
Jan 24, 1995, 11:59:35 AM1/24/95
to
In article <3fv0um$q...@network.ucsd.edu>, Hubert Halkin <hha...@ucsd.edu> writes:
|> The following tk script:
|>
|> for { set i 0 } { $i < 5 } { incr i } {
|> label .$i -text $i
|> bind .$i <Shift-Enter> "puts $i"
|> pack .$i
|> }
|>
|> produces a window such that
|>
|> 1. Just moving the pointer over the window produces nothing
|> 2. Moving the pointer over the window WHILE the shift key is
|> down, prints to stdout the indices of the label visited.
|>
|> Here is my question:
|>
|> By what should I replace <Shift-Enter> in order to produce a window such that
|>
|> 1. Just moving the pointer over the window produces nothing
|> 2. Moving the pointer over the window WHILE button 1 is
|> down, prints to stdout the indices of the label visited.

The answer is complicated.

The event you want is <B1-Enter> (Enter, modified by button 1). The
difficulty is that pressing a button causes an implicit global grab
on the widget that the mouse is in. This is normally the correct
behavior; it prevents surprises when you press the mouse in one widget
and release it in another.

The default global grab can be changed, but it involves co-operation
among the widgets involved. If you look at the bindings for the mouse
in tk.tcl and menu.tcl, you'll get an idea what's involved in passing
the mouse from one widget to another; the behavior that you want
is analogous to the behavior when the mouse is dragged from one menu
button to another.

--
73 de ke9tv/2, Kevin KENNY GE Corporate R&D, Niskayuna, New York, USA

Martin Visser

unread,
Jan 27, 1995, 12:04:41 AM1/27/95
to
In article <3fv0um$q...@network.ucsd.edu>, Hubert Halkin <hha...@ucsd.edu>
wrote:

Just set the event to <Enter> and call your bind command with
"bind_event_handler %s". %s will be substituted with the state field which
coming from the XMotionEvent man page is defined as :-

The state member is set to indicate the logical state of
the pointer buttons and modifier keys just prior to the
event, which is the bitwise inclusive OR of one or more of
the button or modifier key masks: Button1Mask,
Button2Mask, Button3Mask, Button4Mask, Button5Mask,
ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask,
Mod3Mask, Mod4Mask, and Mod5Mask.

--
: Martin Visser
/\/\ : BHP Steel - Slab & Plate Products Division
/ / /\ : Engineering Technology - Computer Systems
/ / / \ : PO Box 1854 Wollongong NSW 2500, AUSTRALIA
/ / / /\ \ : A.C.N. 000 019 625
\ \/ / / / : Phone +61-42-753852
\ / / / : Fax +61-42-757897
\/\/\/ : Internet:MARTIN.M...@msm.bhp.com.au
: X.400 :G=MARTIN I=MC S=VISSER OU=BHPMELMSM
: O=BHP P=BHPMEL04 A=TELEMEMO C=AU

0 new messages