Hi all,
I'm writing a small demo for my image resizing package which displays an
image in a window and allows to navigate with the mouse (drag around /
zoom in and out). The image is displayed on a label.
Zooming is bound to the + and - keys. How do I correctly set the focus
on the label widget? Below is a small example:
============================
package require Tk
package require snit
snit::widget imgviewer {
component disp
constructor {} {
install disp using label $win.l -text "Use + and -" -takefocus true
pack $disp -expand yes -fill both
bind $disp <Key-plus> { puts "Plus" }
bind $disp <Key-minus> { puts "Minus" }
focus $disp ;# how can this be avoided ?
}
}
imgviewer .img
pack .img -expand yes -fill both
pack [ttk::entry .ent]
====================================
It only works if I set the focus explicitly like shown above. The
-takefocus does not have any effect. However this interferes with other
widgets packed into the same frame. If one sets the input focus to teh
entry, then it is impossible to set it back to the label again.
How to handle it correctly?
The full code is here:
https://github.com/auriocus/PhotoResize/blob/master/demo/imgviewer.tcl
Christian
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)