Tk Library Source Code

Check-in [0f25a87991]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Tsw: Code cleanup.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0f25a8799105dc37ab0d2fd02516bd716ab523ca542ee1bef00615165169498b
User & Date: csaba 2025-07-28 13:17:51.558
Context
2025-07-29
13:55
Tsw: Made sure that tsw::toggleswitch and future ttk::toggleswitch widgets won't conflict. Leaf check-in: 79bfeabd8f user: csaba tags: trunk
2025-07-28
13:17
Tsw: Code cleanup. check-in: 0f25a87991 user: csaba tags: trunk
2025-07-25
18:39
Tsw: Optimized the resource management. check-in: 141f0f50ca user: csaba tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to modules/tsw/scripts/toggleswitch.tcl.
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
    bind TswScale <<ThemeChanged>>  { tsw::onThemeChanged %W }

    variable onAndroid
    if {!$onAndroid} {
	bind TswScale <Enter>	    { %W instate !disabled {%W state active} }
	bind TswScale <Leave>	    { %W state !active }
    }
    bind TswScale <B1-Leave>	    { # Preserves the "active" state. }
    bind TswScale <Button-1>	    { tsw::onButton1	%W %x %y }
    bind TswScale <B1-Motion>	    { tsw::onB1Motion	%W %x %y }
    bind TswScale <ButtonRelease-1> { tsw::onButtonRel1	%W }
    bind TswScale <space>	    { tsw::onSpace	%W }
}

#







|







116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
    bind TswScale <<ThemeChanged>>  { tsw::onThemeChanged %W }

    variable onAndroid
    if {!$onAndroid} {
	bind TswScale <Enter>	    { %W instate !disabled {%W state active} }
	bind TswScale <Leave>	    { %W state !active }
    }
    bind TswScale <B1-Leave>	    { # Preserves the active state. }
    bind TswScale <Button-1>	    { tsw::onButton1	%W %x %y }
    bind TswScale <B1-Motion>	    { tsw::onB1Motion	%W %x %y }
    bind TswScale <ButtonRelease-1> { tsw::onButtonRel1	%W }
    bind TswScale <space>	    { tsw::onSpace	%W }
}

#
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
	    return ""
	}

	set curElem [$w identify element $x $y]
	if {[string match "*.slider" $stateArr(prevElem)] &&
	    [string match "*.trough" $curElem]} {
	    startToggling $w
	} elseif {$x < [winfo x $w]} {
	    startMovingLeft $w
	} elseif {$x >= [winfo x $w] + [winfo width $w]} {
	    startMovingRight $w
	}

	set stateArr(prevElem) $curElem
    } else {
	variable scaled4
	if {!$stateArr(dragging) && abs($x - $stateArr(startX)) > $scaled4} {







|

|







636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
	    return ""
	}

	set curElem [$w identify element $x $y]
	if {[string match "*.slider" $stateArr(prevElem)] &&
	    [string match "*.trough" $curElem]} {
	    startToggling $w
	} elseif {$x < 0} {
	    startMovingLeft $w
	} elseif {$x >= [winfo width $w]} {
	    startMovingRight $w
	}

	set stateArr(prevElem) $curElem
    } else {
	variable scaled4
	if {!$stateArr(dragging) && abs($x - $stateArr(startX)) > $scaled4} {
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762

    set val [expr {$val - 1}]
    $w set $val

    if {$val > [$w cget -from]} {
	after 10 [list tsw::moveLeft $w $val]
    } else {
	$w state selected	;# restores the original selected state flag
	set win [winfo parent $w]
	::$win switchstate 0

	upvar ::tsw::ns${win}::data data
	set data(moveState) moved
    }
}







|







748
749
750
751
752
753
754
755
756
757
758
759
760
761
762

    set val [expr {$val - 1}]
    $w set $val

    if {$val > [$w cget -from]} {
	after 10 [list tsw::moveLeft $w $val]
    } else {
	$w state selected	;# restores the original selected state
	set win [winfo parent $w]
	::$win switchstate 0

	upvar ::tsw::ns${win}::data data
	set data(moveState) moved
    }
}
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799

    set val [expr {$val + 1}]
    $w set $val

    if {$val < [$w cget -to]} {
	after 10 [list tsw::moveRight $w $val]
    } else {
	$w state !selected	;# restores the original !selected state flag
	set win [winfo parent $w]
	::$win switchstate 1

	upvar ::tsw::ns${win}::data data
	set data(moveState) moved
    }
}







|







785
786
787
788
789
790
791
792
793
794
795
796
797
798
799

    set val [expr {$val + 1}]
    $w set $val

    if {$val < [$w cget -to]} {
	after 10 [list tsw::moveRight $w $val]
    } else {
	$w state !selected	;# restores the original !selected state
	set win [winfo parent $w]
	::$win switchstate 1

	upvar ::tsw::ns${win}::data data
	set data(moveState) moved
    }
}