2017-07-05 16 views
0

我與TCL 8.6的Tcl Tk的雙擊綁定由另一個結合

我(通過Nehmeti)有兩個tablelists工作受阻:

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)]] 

兩個tablelist有綁定:

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] 

klickZeile的方法看起來像這樣

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 
} 

看來,方法klickZeile阻止我的雙擊綁定,doubleKlickMesswerte方法沒有被調用。

在klickZeile中選擇兩個表中的兩個對應的行。

我試圖通過「激活$行,選擇清除0結束和選擇集$行$行」註釋掉這兩個塊。在這種情況下,doubleKlickMesswerte被調用,但不幸的是,方法klickZeile無法正常工作。看來在這種情況下,該方法爲之前選擇的行選擇對應的行。

所以,我有兩個問題:

我如何防止阻塞雙擊結合的方法klickZeile? 或者,如果沒有辦法做到這一點,我該怎麼辦,讓方法「klickZeile」正常工作,無需額外的選擇和激活?

感謝您的幫助!

回答

0

沒有修飾符(如Control)的鼠標單擊事件(至少單/雙/三)將在綁定到三元組時設置並且用戶三次點擊目標元素時觸發。 GUI無法預測再次點擊即將到來。它必須首先發送單擊事件,接着是雙擊,然後是三聯。

你最好的選擇是使用的改性劑,例如,因爲這是唯一的並且不依賴於序列,只要該控制按鈕最初被按壓)

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 }