From: Maarten <ma...@sn...> - 2006-10-23 07:19:54
|
Mads Lindstr=F8m wrote: > Is there anybody who has an example of using context sensitive popup > menus? > =20 The following code (below) is a sample I posted several weeks ago as a=20 question. For some reason not yet clear, the 'on command' part doesn't=20 work properly, however you can register the commands in the frame. (In=20 the sample, please uncomment the 'set f ...' part.) kind regards, Maarten P.S. I have no experience with context menu's in a listbox, but 'select'=20 won't work for right click only and with the 'reactive' interface you=20 probably have to calculate the selected item yourself) If you find a=20 better solution I would be very interested. gui :: IO () gui =3D do f <- frame [ text :=3D "Hello world!" ] m <- menuPane [ text :=3D "&Menu" ] m1 <- menuItem m [ text :=3D "Menu m1", on command :=3D putStrLn "menu m= 1"] -- set f [ on (menu m1) :=3D putStrLn "menu m1" ] menuLine m sub <- menuPane [text :=3D "Sub menu"] ms1 <- menuItem sub [ text :=3D "submenu ms1", on command :=3D putStrLn=20 "submenu ms1" ] -- set f [ on (menu ms1) :=3D putStrLn "submenu ms1" ] menuSub m sub [ text :=3D "Sub" ] menuItem m [text :=3D "E&xit", on command :=3D close f] set f [menuBar :=3D [m], on mouse :=3D mouseEvent f, clientSize :=3D sz = 200=20 200 ] return () mouseEvent f eventMouse =3D do case eventMouse of MouseRightDown mousePoint _ -> doPopup f mousePoint _ -> return () doPopup f mousePoint =3D do m <- makePopupMenu f "&Popup" "Doesnt' work..." menuPopup m mousePoint f objectDelete m makePopupMenu f c t =3D do mp <- menuPane [ text :=3D c ] mp1 <- menuItem mp [ text :=3D "Popup mp1", on command :=3D putStrLn "po= pup=20 mp1"] -- set f [ on (menu mp1) :=3D putStrLn "popup mp1" ] menuLine mp sub <- menuPane [text :=3D "more text"] mps1 <- menuItem sub [ text :=3D "Popup mps1", on command :=3D putStrLn=20 "popup mps1"] menuSub mp sub [ text :=3D "Sub" ] -- set f [ on (menu mps1) :=3D putStrLn "popup mps1" ] return mp > I am especially interested in an example with a listbox, where one can > right-click an element and get a popup menu. > > > Greetings, > > Mads Lindstr=F8m > > > > -----------------------------------------------------------------------= -- > Using Tomcat but need to do more? Need to support web services, securit= y? > Get stuff done quickly with pre-integrated technology to make your job = easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geron= imo > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat= =3D121642 > _______________________________________________ > wxhaskell-users mailing list > wxh...@li... > https://lists.sourceforge.net/lists/listinfo/wxhaskell-users > > > =20 |