• Tooltip not working in combination with bindtags

    From Alexandru@21:1/5 to All on Fri Jan 28 05:02:47 2022
    A while ago I posted the implementation of a swipe action over checkbuttons in order to quickly toggle their state:

    https://groups.google.com/g/comp.lang.tcl/c/MS3YKU-uQkU/m/SL76RvNfAgAJ

    Now I realize, that the bindings for the tooltips are not working anymore for those checkbuttons that have the swipe action.

    The tooltips are implemented as below. The SwipeInit procedure calls this command:

    bindtags $parentframe.$child [list $parentframe all TCheckbutton]

    Without it, the tooltips are working.
    Question: How can a make both work?

    Many thanks
    Alexandru

    proc ::TooltipSet {widgets text {textvariable ""} {delay 1000} {prependcmd ""} {appendcmd ""}} {
    if {$text != ""} {
    # 2) Adjusted timings and added key and button bindings. These seem to
    # make artifacts tolerably rare.
    set textlines [string map {". " ".\n"} $text]
    if {$textvariable==""} {
    foreach widget $widgets {
    bind $widget <Any-Enter> [list after $delay [list ::TooltipShow %W $textlines $prependcmd $appendcmd]]
    bind $widget <Any-Leave> [list after [expr $delay/2] [list destroy %W.tooltip]]
    bind $widget <Any-KeyPress> [list after [expr $delay/2] [list destroy %W.tooltip]]
    bind $widget <Any-Button> [list after [expr $delay/2] [list destroy %W.tooltip]]
    }
    } else {
    set text [string map {"\n" " "} $text]
    foreach widget $widgets {
    bind $widget <Any-Enter> "set $textvariable [list $text]; after $delay [list [list ::TooltipShow %W $textlines $prependcmd $appendcmd]]"
    bind $widget <Any-Leave> "set $textvariable {}; after [expr $delay/2] [list [list destroy %W.tooltip]]"
    bind $widget <Any-KeyPress> "set $textvariable {}; after [expr $delay/2] [list [list destroy %W.tooltip]]"
    bind $widget <Any-Button> "set $textvariable {}; after [expr $delay/2] [list [list destroy %W.tooltip]]"
    }
    }
    }
    }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Leitgeb@21:1/5 to Alexandru on Fri Jan 28 15:00:20 2022
    Alexandru <[email protected]> wrote:
    A while ago I posted the implementation of a swipe action over checkbuttons in order to quickly toggle their state:
    https://groups.google.com/g/comp.lang.tcl/c/MS3YKU-uQkU/m/SL76RvNfAgAJ
    Now I realize, that the bindings for the tooltips are not working anymore for those checkbuttons that have the swipe action.
    The tooltips are implemented as below. The SwipeInit procedure calls this command:
    bindtags $parentframe.$child [list $parentframe all TCheckbutton]
    Without it, the tooltips are working.

    The default bindtags for ttk::checkbox is:
    % bindtags [ttk::checkbutton .tcb]
    .tcb TCheckbutton . all

    further down, you have:

    bind $widget <...> ...

    of which I'm not sure if it ever fires, when the widget itself
    is not in its own bindtags.

    Question: How can a make both work?

    my guess would be either to change the bind to some special Tag,
    which you would add to the checkbox's bindtags, or just to add
    the widget-path itself (and not just its parent) to bindtags.

    bindtags $parentframe.$child [list $parentframe $parentframe.$child all TCheckbutton]
    (or any other order of those)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alexandru@21:1/5 to Andreas Leitgeb on Fri Jan 28 10:36:46 2022
    Andreas Leitgeb schrieb am Freitag, 28. Januar 2022 um 16:00:24 UTC+1:
    Alexandru <[email protected]> wrote:
    A while ago I posted the implementation of a swipe action over checkbuttons in order to quickly toggle their state:
    https://groups.google.com/g/comp.lang.tcl/c/MS3YKU-uQkU/m/SL76RvNfAgAJ
    Now I realize, that the bindings for the tooltips are not working anymore for those checkbuttons that have the swipe action.
    The tooltips are implemented as below. The SwipeInit procedure calls this command:
    bindtags $parentframe.$child [list $parentframe all TCheckbutton]
    Without it, the tooltips are working.
    The default bindtags for ttk::checkbox is:
    % bindtags [ttk::checkbutton .tcb]
    .tcb TCheckbutton . all

    further down, you have:

    bind $widget <...> ...

    of which I'm not sure if it ever fires, when the widget itself
    is not in its own bindtags.
    Question: How can a make both work?
    my guess would be either to change the bind to some special Tag,
    which you would add to the checkbox's bindtags, or just to add
    the widget-path itself (and not just its parent) to bindtags.

    bindtags $parentframe.$child [list $parentframe $parentframe.$child all TCheckbutton]
    (or any other order of those)

    Oh, thank you. After seeing your code, I realized my mistake.

    I did

    bindtags $parentframe.$child [list $parentframe all TCheckbutton $child]

    instead

    bindtags $parentframe.$child [list $parentframe all TCheckbutton $parentframe.$child]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)