Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mouse click 2

Status
Not open for further replies.

stewang

Programmer
Aug 21, 2003
77
NZ
Hello all:
I want to pop up a window when I click
on the right mouse in the listbox, would
anyone give me some idea how to implement this, please.

rgds
stewang
Code:
button .b -text "button" -bg white      -command newWindow
pack .b

proc newWindow {} {
 toplevel .t
 global lv
 set lv {"test" "test"}
 frame .t.listframe
 listbox .t.listframe.namelist -listvariable lv
 pack .t.listframe.namelist -side top
 pack .t.listframe
}
 
Hi,
you can bind the call to procedure newWindow to Button-3 event of listbox

bind .t.listframe.namelist <Button-3> {#command to generate/popup new window}

for e.g. this will pop up a new toplevel

bind .t.listframe.namelist <Button-3> {toplevel .newwind}


I hope this will help you.
 
An example with a menu:
Code:
  menu .m -title popup
  .m add command -label Ok -command {tk_messageBox -message Ok}
  label .l -text &quot;right click the mouse to open the menu&quot;
  pack .l -pady 20 -padx 20
  bind . <3> {eval .m post [winfo pointerxy .]}
HTH

ulis
 
Thanks for ramsunder and ulis give me different examples, they work very well.


rgds
stewang

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top