texlive[58813] Master/tlpkg/tltcl/tltcl.tcl: Better bindings for

commits+siepo at tug.org commits+siepo at tug.org
Sat Apr 10 15:19:50 CEST 2021


Revision: 58813
          http://tug.org/svn/texlive?view=revision&revision=58813
Author:   siepo
Date:     2021-04-10 15:19:50 +0200 (Sat, 10 Apr 2021)
Log Message:
-----------
Better bindings for Linux Unicode check- and radiobuttons

Modified Paths:
--------------
    trunk/Master/tlpkg/tltcl/tltcl.tcl

Modified: trunk/Master/tlpkg/tltcl/tltcl.tcl
===================================================================
--- trunk/Master/tlpkg/tltcl/tltcl.tcl	2021-04-10 13:03:22 UTC (rev 58812)
+++ trunk/Master/tlpkg/tltcl/tltcl.tcl	2021-04-10 13:19:50 UTC (rev 58813)
@@ -792,10 +792,14 @@
 
 # on unix/linux the original indicators are hard-coded as bitmaps,
 # which cannot scale with the rest of the interface.
-# the hack below replaces them with unicode characters.
+# the hack below replaces them with unicode characters, which are scaled
+# along with other text.
 # This is implemented by removing the original indicators and prepending
 # a unicode symbol and a unicode wide space to the text label.
 
+# The combobox down arrow and the treeview triangles (directory browser)
+# are still unscaled.
+
 if $::plain_unix {
 
   # from General Punctuation, 2000-206f
@@ -811,7 +815,7 @@
   ttk::style layout TCheckbutton "Checkbutton.padding -sticky nswe -children {Checkbutton.focus -side left -sticky w -children {Checkbutton.label -sticky nswe}}"
   ttk::style layout TRadiobutton "Radiobutton.padding -sticky nswe -children {Radiobutton.focus -side left -sticky w -children {Radiobutton.label -sticky nswe}}"
 
-  proc tlupdate_check {w} {
+  proc tlupdate_check {w n e o} { ; # n, e, o added to keep trace happy
     upvar [$w cget -variable] v
     set s [$w cget -text]
     set ck [expr {$v ? $::chk1 : $::chk0}]
@@ -821,35 +825,39 @@
     } else {
       set s "$ck$::wsp$s"
     }
+    if {[string length $s] == 2} {
+      # indicator plus wide space plus empty string. Remove wide space.
+      set s [string range $s 0 0]
+    }
     $w configure -text $s
-    return $w
   }
-  bind TCheckbutton <ButtonRelease-1> {+tlupdate_check %W}
-  bind TCheckbutton <Key-space> {+tlupdate_check %W}
-  bind TCheckbutton <Map> {+tlupdate_check %W}
+  bind TCheckbutton <Map> {+tlupdate_check %W n e o}
+  bind TCheckbutton <Map> {+trace add variable [%W cget -variable] write \
+                               [list tlupdate_check %W]}
+  bind TCheckbutton <Unmap> \
+    {+trace remove variable [%W cget -variable] write [list tlupdate_check %W]}
 
-  proc tlupdate_radio {w} {
+  proc tlupdate_radio {w n e o} {
     upvar [$w cget -variable] v
     set ck [expr {$v eq [$w cget -value] ? $::rad1 : $::rad0}]
     set s [$w cget -text]
     set s0 [string index $s 0]
     if {$s0 eq $::rad0 || $s0 eq $::rad1} {
-      $w configure -text "$ck$::wsp[string range $s 2 end]"
+      set s "$ck$::wsp[string range $s 2 end]"
     } else {
-      $w configure -text "$ck$::wsp$s"
+      set s "$ck$::wsp$s"
     }
-  }
-  proc tlupdate_radios {w} {
-    upvar [$w cget -variable] v
-    foreach sibling [winfo children [winfo parent $w]] {
-      if {[winfo class $sibling] eq "TRadiobutton" &&
-            [$sibling cget -variable] eq [$w cget -variable]
-          && ![$sibling instate disabled]} {
-        tlupdate_radio $sibling
-      }
+    if {[string length $s] == 2} {
+      # indicator plus wide space plus empty string. Remove wide space.
+      set s [string range $s 0 0]
     }
+    $w configure -text $s
   }
-  bind TRadiobutton <ButtonRelease-1> {+tlupdate_radios %W}
-  bind TRadiobutton <Key-space> {+tlupdate_radios %W}
-  bind TRadiobutton <Map> {+tlupdate_radio %W}
+
+  bind TRadiobutton <Map> {+tlupdate_radio %W n e o}
+  bind TRadiobutton <Map> {+trace add variable [%W cget -variable] write \
+                               [list tlupdate_radio %W]}
+  bind TRadiobutton <Unmap> \
+    {+trace remove variable [%W cget -variable] write [list tlupdate_radio %W]}
 }
+



More information about the tex-live-commits mailing list.