event bindings which pass the event himself first..? 
Author Message
 event bindings which pass the event himself first..?

Hello,

my problem is, that I want to bind a command to some events - but after
these events passed themselves.
I need this for displaying the current line of a text widgets cursor
position by a label next to the text widget.

For example:

bind .text <Key-Down> {

    # here should pass the <Key-Down> event himself first ...
    ???

    # ... and then I wanna refresh a variable with the current
'insert'-index by a proc 'RefreshCursor'

    RefreshCursor

Quote:
}

Is this possible?
And is it possible to define a kind of 'multi-event' including <Key-Down>,
<Key-Up>, <Key-Return> and some other "line changing" events?

It would be great, if someone could help me. Thank you.

Anne



Tue, 02 Mar 2004 03:15:27 GMT  
 event bindings which pass the event himself first..?

| Hello,
|
| my problem is, that I want to bind a command to some events - but after
| these events passed themselves.
| I need this for displaying the current line of a text widgets cursor
| position by a label next to the text widget.
|
| For example:
|
| bind .text <Key-Down> {
|
|     # here should pass the <Key-Down> event himself first ...
|     ???
|     # ... and then I wanna refresh a variable with the current
| 'insert'-index by a proc 'RefreshCursor'
|
|     after idle RefreshCursor
     ^^^^
| }
|
| Is this possible?

Try inserting "after idle command" or "after 0 command" in the binding (above), they
shouldn't fire until the Key-Down action is completed.

| And is it possible to define a kind of 'multi-event' including <Key-Down>,
| <Key-Up>, <Key-Return> and some other "line changing" events?

Not sure what you goal is, you can always bind to the <Any-Key> and determine what
key is pressed from there.

|
| It would be great, if someone could help me. Thank you.
|
| Anne
|

Tom Wilkason



Tue, 02 Mar 2004 04:13:38 GMT  
 event bindings which pass the event himself first..?

Quote:

> Hello,

> my problem is, that I want to bind a command to some events - but after
> these events passed themselves.
> I need this for displaying the current line of a text widgets cursor
> position by a label next to the text widget.

> For example:

> bind .text <Key-Down> {

>     # here should pass the <Key-Down> event himself first ...
>     ???

>     # ... and then I wanna refresh a variable with the current
> 'insert'-index by a proc 'RefreshCursor'

>     RefreshCursor
> }

> Is this possible?
> And is it possible to define a kind of 'multi-event' including <Key-Down>,
> <Key-Up>, <Key-Return> and some other "line changing" events?

> It would be great, if someone could help me. Thank you.

> Anne

bindtags is your friend here. [bindtags ..text] will return ".text Text . all"
which says bindings on .text go first, then bindings for the Text class
(which is where all the definitions for how the text widget reacts to user
input) then any bindings on the top level ".", and then any bindings set for
all. You want your bindings to go AFTER the Text class bindings, so just create
a new name for your set of bindings
  bind MyName <Key>  RefreshCursor
  bind MyName <Button> RefreshCursor
and then insert it into the list of bindings that are on the widget to go LAST
    bindtags .text {.text Text . all MyName}

Bruce



Tue, 02 Mar 2004 05:40:46 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Event Binding and Variable Passing

2. Tcl Event Loop vs TK Event Loop issues with Asynchronous Events

3. Receiving Apple Events in a RB app (HandleAppleEvent event)

4. Event structure always capturing events, no matter where it is placed in a VI

5. Boolean controls don't respond to input when inside an event in the event structure

6. using multiple event structures polling for panel closing event

7. Event case missing mouse events on active-x component

8. Event Structure and Events

9. Disambiguating java.awt.Event and vrml.Event?

10. Single Event -> Multiple Event

11. pygame.event.Event?

12. Question: event.widget, event.type

 

 
Powered by phpBB® Forum Software