Hello out there,I just found out that if I change <Keypress> to <KeyPress> it produces
consider the following script:
---
package require Tk
set t [text .t -width 40 -height 10]
pack $t
# the following line will error out with the message
# bad event type or keysym "Keypress"
event generate $t <Keypress> -keysym Return
event generate $t <KeyPress> -keysym a
---
When I comment the offending line out the following line executes
(using the same <Keypress> ???) but the 'a' doesn't show up.I must be
doing something wrong - but what?
Any help or advice will be greatly appreciated.
Helmut
PS: This is with Tcl 8.6.10 on 64 bit Windows 10
PS: This is with Tcl 8.6.10 on 64 bit Windows 10I just found out that if I change <Keypress> to <KeyPress> it produces
no error - but no visible result either. Any advice anybody?
Hello out there,
consider the following script:
---
package require Tk
set t [text .t -width 40 -height 10]
pack $t
# the following line will error out with the message
# bad event type or keysym "Keypress"
event generate $t <Keypress> -keysym Return
event generate $t <KeyPress> -keysym a
---
When I comment the offending line out the following line executes
(using the same <Keypress> ???) but the 'a' doesn't show up.I must be
doing something wrong - but what?
Any help or advice will be greatly appreciated.
Helmut
PS: This is with Tcl 8.6.10 on 64 bit Windows 10
Helmut Giese <hgiese@ratiosoft.com> schrieb:
Hello out there,I just found out that if I change <Keypress> to <KeyPress> it produces
consider the following script:
---
package require Tk
set t [text .t -width 40 -height 10]
pack $t
# the following line will error out with the message
# bad event type or keysym "Keypress"
event generate $t <Keypress> -keysym Return
event generate $t <KeyPress> -keysym a
---
When I comment the offending line out the following line executes
(using the same <Keypress> ???) but the 'a' doesn't show up.I must be
doing something wrong - but what?
Any help or advice will be greatly appreciated.
Helmut
PS: This is with Tcl 8.6.10 on 64 bit Windows 10
no error - but no visible result either. Any advice anybody?
PS: This is with Tcl 8.6.10 on 64 bit Windows 10I just found out that if I change <Keypress> to <KeyPress> it produces
no error - but no visible result either. Any advice anybody?
The binding that inserts a character on a text window is bound to the Text widget class binding tag (Text in this case), not the window binding tag (.t), see
bindtags .t
bind Text <KeyPress>
However
event generate .t ...
apparently only sends the event to the window binding tag (.t) so the bindings to the Text tag are not fired. I'm not sure how you might sent an event to other window binding tags.
You might use the tk::TextInsert command to get the character inserted.
bindtags .t.t Text . all
bind Text<Shift-Button-5> <Shift-Button-4> <Button-5> <Button-4>
On 6/2/22 20:48, clt.to.davebr@dfgh.net wrote:
PS: This is with Tcl 8.6.10 on 64 bit Windows 10I just found out that if I change <Keypress> to <KeyPress> it produces
no error - but no visible result either. Any advice anybody?
The binding that inserts a character on a text window is bound to the Text widget class binding tag (Text in this case), not the window binding tag (.t), see
bindtags .t
bind Text <KeyPress>
However
event generate .t ...
apparently only sends the event to the window binding tag (.t) so the bindings to the Text tag are not fired. I'm not sure how you might sent an event to other window binding tags.
You might use the tk::TextInsert command to get the character inserted.
Ah, are you sure about that. At least on Linux that is not what I see:
bindtags .t.t Text . all
bind Text<Shift-Button-5> <Shift-Button-4> <Button-5> <Button-4>
<Shift-MouseWheel> <MouseWheel> <B2-Motion> <Button-2> <Control-Key-h> <<TkAccentBackspace>> <<TkClearIMEMarkedText>> <<TkEndIMEMarkedText>> <<TkStartIMEMarkedText>> <Meta-Key-Delete> <Meta-Key-BackSpace> <Meta-Key-greater> <Meta-Key-less> <Meta-Key-f> <Meta-Key-d>
<Meta-Key-b> <<Redo>> <<Undo>> <Control-Key-t> <Control-Key-o> <Control-Key-k> <Control-Key-d> <Key-KP_Enter> <Key-Escape>
<Control-Key> <Meta-Key> <Alt-Key> <Key> <Key-Insert> <<PasteSelection>> <<Clear>> <<Paste>> <<Copy>> <<Cut>> <<SelectNone>> <<SelectAll>> <Shift-Key-Select> <Control-Shift-Key-space> <Key-Select>
<Control-Key-space> <Key-BackSpace> <Key-Delete> <Key-Return>
<Control-Key-i> <Control-Shift-Key-Tab> <Control-Key-Tab>
<Shift-Key-Tab> <Key-Tab> <Control-Shift-Key-End> <Control-Key-End> <Control-Shift-Key-Home> <Control-Key-Home> <<SelectLineEnd>>
<<LineEnd>> <<SelectLineStart>> <<LineStart>> <Control-Key-Next> <Control-Key-Prior> <Shift-Key-Next> <Key-Next> <Shift-Key-Prior>
<Key-Prior> <<SelectNextPara>> <<SelectPrevPara>> <<SelectNextWord>> <<SelectPrevWord>> <<NextPara>> <<PrevPara>> <<NextWord>> <<PrevWord>> <<SelectNextLine>> <<SelectPrevLine>> <<SelectNextChar>>
<<SelectPrevChar>> <<NextLine>> <<PrevLine>> <<NextChar>> <<PrevChar>> <Control-B1-Motion> <Double-Control-Button-1> <Control-Button-1> <ButtonRelease-1> <B1-Enter> <B1-Leave> <Triple-Shift-Button-1> <Double-Shift-Button-1> <Shift-Button-1> <Triple-Button-1>
<Double-Button-1> <B1-Motion> <Button-1>
There is no <KeyPress> event. There is a <Key> event.
From: Robert Heller <heller@deepsoft.com>
Date: Fri Jun 03 13:30:02 GMT 2022
Subject: Problem with 'event generate'
There is no <KeyPress> event. There is a <Key> event.
From man 3tk bind:
EVENT TYPES
Configure KeyPress, Key ResizeRequest
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 497 |
Nodes: | 16 (2 / 14) |
Uptime: | 68:34:27 |
Calls: | 9,766 |
Calls today: | 7 |
Files: | 13,747 |
Messages: | 6,186,073 |