An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
how to provide options to hwtk component table cell while right clicking a cell?
@tinh Please help
From HM14, a menu is attached to table cell as default, but to show it, use option -cellmenucommand
You have to provide a tcl proc (not menu name)
Purpose of that proc is to customize the cell menu (already created as default, you don't need to create it)
That proc accepts %M as argument to refer cell menu name, then you can use it to add or remove menu commands suitable with each cell type
Example
hwtk::table .myTable -cellmenucommand {p_PrepareMenu %M %C}
.myTable columncreate name -text name
.myTable columncreate id -text id
.myTable rowinsert end row1 -values {name comp1 id 1001}
.myTable rowinsert end row2 -values {name comp2 id 3000}
proc p_PrepareMenu {mnu column} {
$mnu delete 0 end
switch -- $column {
name {
$mnu add command -label Rename
}
id {
$mnu add command -label Renumber
As I see, when creating hwtk table, option -menu will attach a menu with event 'right click' on header of column 0
When creating a column, option -headermenu will attach a menu with event 'right click' on header of that column.
Hi Tin,
I am getting error on '$mnu delete 0 end'
and I am getting error on :
@tinh Pls help
It is hwtk menu
Refer to hwtk gui to see its method
Because it's a hwtk menu, sub commands 'delete' and 'add' are changed to methods 'clear' and 'item'
$mnu clear
$mnu item Rename -caption Rename -command {puts 'write a proc to rename comp'}
id {
$mnu item Renumber -caption Renumber -command {puts 'write a proc to renumber comp'}
}