2017-07-05 2 views
0

blockiert ich mit tcl arbeiten 8.6Tcl Tk Doppelklick Bindung wird durch eine andere Bindung

ich zwei tablelists habe (von Nehmeti):

set pfd(frMain) [frame $fr.frMain] 
set pfd(bottomFr) [frame $pfd(frMain).bfr] 
set pfd(panWin) [panedwindow $pfd(bottomFr).pw -showhandle 1 -orient vertical -sashpad 0 -sashrelief raised -sashwidth 2] 
set pfd(frKlaffNeupkt) [frame $pfd(panWin).frKlaffNeupkt] 
pack $pfd(frMesswerte) -anchor nw -expand 0 -fill both 
pack $pfd(frKlaffNeupkt) -anchor nw -expand 0 -fill both 
pack $pfd(panWin) -anchor nw -expand 1 -fill both 
$pfd(panWin) add $pfd(frMesswerte) $pfd(frKlaffNeupkt) 
set pfd(tali_mw) [tablelist::tablelist $pfd(frMesswerte).li.tali_mw \ 
        -columns {0 "oid" l \ 
          0 "status" l \    
          0 "art" l \ 
          0 "sollTyp" l \ 
          0 "Nr" l \ 
          0 "Typ" l \ 
          0 "Gst" l \ 
          0 "Hz" r \ 
          0 "V" r \ 
          0 "S" r \ 
          0 "Q" r \ 
          0 "L" r \ 
          0 "AK" l\ 
          0 "LSEX" l \ 
          0 "lfdNrGes" l}\ 
        -exportselection 0 \ 
        -labelbackground #EEEEEE \ 
        -background white \ 
        -labelfont $tableheadfont\ 
        -font $tableinhfont\ 
        -stretch 12\ 
        -selectbackground $vmVConfig::setVar(activeBG) \ 
        -selectforeground $vmVConfig::setVar(activeFG) \ 
        -selectmode single\ 
        -borderwidth 1 \ 
        -labelborderwidth 1 \ 
        -selectborderwidth 0 \ 
        -tooltipaddcommand [::itcl::code $this tooltipAddCmd] \ 
        -tooltipdelcommand [::itcl::code $this tooltipDelCmd] \ 
        -xscrollcommand [list vmTkTools::configSB "h" $pfd(mw_scrx)]\ 
        -yscrollcommand [list vmTkTools::configSB "v" $pfd(mw_scry)]] 


set pfd(noteb) [iwidgets::notebook $pfd(frKlaffNeupkt).noteb] 
pack $pfd(noteb) -anchor nw -expand 1 -fill both 
set pfd(frKlaffungen) [$pfd(noteb) add -label Klaffungen] 

set pfd(tali_klaff) [tablelist::tablelist $pfd(frKlaffungen).li.tali_klaff \ 
         -columns {0 "oid" l 0 "Nr" l 0 "dX" r 0 "dY" r 0 "GwX" r 0 "GwY" r 0 "Rdz" r 0 "lfdNrGes" r}\ 
         -exportselection 0 \ 
         -labelbackground #EEEEEE \ 
         -background white \ 
         -labelfont $tableheadfont\ 
         -font $tableinhfont\ 
         -stretch 7\ 
         -selectbackground $vmVConfig::setVar(activeBG) \ 
         -selectforeground $vmVConfig::setVar(activeFG) \ 
         -selectmode single\ 
         -labelrelief groove \ 
         -borderwidth 1 \ 
         -labelborderwidth 1 \ 
         -selectborderwidth 0 \ 
         -xscrollcommand [list vmTkTools::configSB "h" $pfd(klaff_scrx)]\ 
         -yscrollcommand [list vmTkTools::configSB "v" $pfd(klaff_scry)]] 

Beide table Bindungen haben:

set body [$pfd(tali_mw) bodypath] 
bind $body <Button-1> +[::itcl::code $this klickZeile %x %y %W] 
bind $body <Double-1> +[::itcl::code $this doubleKlickMesswerte %x %y %W] 

set body [$pfd(tali_klaff) bodypath] 
bind $body <Button-1> [::itcl::code $this klickZeile %x %y %W] 

Das Verfahren sieht klickZeile wie diese

itcl::body vmMaskHelmert::klickZeile {x y W} { 
    puts "klickZeile" 

    delCommonKreuz 

    foreach {pfad xC yC} [tablelist::convEventFields $W $x $y] {} 
    set row [$pfad containing $yC] 
    if {$row == -1} { 
     set row end 
    } 

    if {[string first "tali_mw" $W] != -1} { 
     # select the row 
     $pfd(tali_mw) activate $row 
     $pfd(tali_mw) selection clear 0 end 
     $pfd(tali_mw) selection set $row $row 
     anzeigePpMp 
    } else { 
     $pfd(tali_klaff) activate $row 
     $pfd(tali_klaff) selection clear 0 end 
     $pfd(tali_klaff) selection set $row $row 
     anzeigePpMp4Klaff 
    } 
    return 
} 

Es scheint, dass die Methode klickZeile meine Doppelklick-Bindung blockiert, die Methode doubleKlickMesswerte wird nicht aufgerufen.

In der klickZeile werden zwei entsprechende Zeilen in beiden Tabellenlisten ausgewählt.

Ich habe versucht, die beiden Blöcke mit "aktivieren $ Zeile, Auswahl löschen 0 Ende und Auswahlmenge $ Zeile $ Zeile" auskommentieren. In diesem Fall wird doubleKlickMesswerte aufgerufen, aber leider funktioniert die Methode klickZeile nicht korrekt. In diesem Fall wählt die Methode die entsprechende Zeile für die zuvor ausgewählte Zeile aus.

Also habe ich zwei Fragen bekam:

Wie kann ich die Methode klickZeile blockiert den Doppelklick Bindung verhindern? Oder, wenn es dazu keinen Weg gibt, was kann ich tun, damit die Methode "klickZeile" ohne zusätzliche Auswahl und Aktivierung korrekt funktioniert?

Danke für Ihre Hilfe!

Antwort

0

Mausklick-Ereignisse (mindestens Single/Double/Triple) ohne Modifikatoren (wie Control) werden alle ausgelöst, wenn eine Bindung an Triple eingerichtet wird und der Benutzer das Zielelement dreimal anklickt. Die GUI kann nicht vorhersagen, dass ein weiterer Klick kommt. Es muss zuerst das Single-Click-Event, dann das Double und dann das Triple gesendet werden.

Ihre beste Alternative ist, einen Modifikator, wie ein zu verwenden, da diese eindeutig und hängen nicht von der Sequenz, solange die Steuertaste zuerst gedrückt wird;)

proc doClick { widget } { 
    puts "You clicked [$widget cget -text]" 
} 

proc doControlClick { widget } { 
    puts "You control-clicked [$widget cget -text]" 
} 

set label_1 [label .l1 -text "This is label 1"] 
pack $label_1 -side top -fill both 


bind $label_1 <Control-Button-1> { doControlClick %W } 
bind $label_1 <Button-1> { doClick %W }