Tcl Source Code

View Ticket
Login
Ticket UUID: 3570146
Title: right click on ttk::notebook tab
Type: Patch Version: TIP Implementation
Submitter: jromier Created on: 2012-09-20 15:59:57
Subsystem: 10. Objects Assigned To: msofer
Priority: 5 Medium Severity:
Status: Pending Last Modified: 2012-09-23 01:17:03
Resolution: Invalid Closed By: dkf
    Closed on: 2012-09-22 18:17:03
Description:
Hello,

Based on Tcl/Tk 8.5.12.

For a personal need, I updated the ttk::notebook.tcl file in order to have a virtual event notification when a right click appends on a notebook tab.
The new virtual event generated is <<NotebookTabRightClick>> with options/values -x # -y # -data tab_index.

As I did not want to re-compile the wish85.exe, I just modified the notebook.tcl file (instead ttkNotebook.c file).
The waiting result is OK.

Modification is:
Add:
  bind TNotebook <ButtonRelease-3>{ ttk::notebook::RightClick %W %x %y }

  # RightClick $nb $x $y --
  #ButtonRelease-3 binding for notebook widgets.
  #Activate the tab under the mouse cursor, if any.
  #And send an virtual event
  #
  proc ttk::notebook::RightClick {w x y} {
    set index [$w index @$x,$y]
    if {$index ne ""} {
ActivateTab $w $index
    }
    event generate $w <<NotebookTabRightClick>> -x $x -y $y -data $index
  }
End Add.

On a tcl script, you just have to bind this virtual event:
  bind $nbk <<NotebookTabRightClick>> "notebook_right_click $nbk %d %x %y"

The benefit of this modification is to have the way to open a popup menu on the notebook tab on a right-clic, as it's possible in some applications.

So, maybe you would be able to add this feature on a next release.

Thank you and sorry for my english that is often 'frenchy'

Jean Romier
PLANAR SAS
France
User Comments: dkf added on 2012-09-23 01:17:02:
You should submit this to the Tk project tracker, as it is an alteration to the Tk toolkit and not to the Tcl language itself.

jromier added on 2012-09-20 22:59:58:

File Added - 453519: notebook.tcl

Attachments: