From: Mads <mad...@ya...> - 2006-10-22 14:16:22
|
Hi all Is there anybody who has an example of using context sensitive popup menus? 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 |
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 |
From: Doaitse S. <do...@cs...> - 2007-02-16 12:41:16
|
When trying to run even the smallert wx program in my Mac OS X 10.4, =20 Intel: module Main where import Graphics.UI.WX import EnableGUI main :: IO () main =3D start hello hello :: IO () hello =3D do f <- frame [text :=3D "Hello!"] quit <- button f [text :=3D "Quit", on command :=3D close f] set f [layout :=3D widget quit] I get: koshka:~/Desktop/TestWX doaitse$ ghci -package wx -fglasgow-exts =20 Main.hs ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.6, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \____/\/ /_/\____/|_| Type :? for help. Loading package base ... linking ... done. Loading package haskell98 ... linking ... done. Loading package wxcore-0.10.1 ... linking ... done. Loading package wx-0.10.1 ... linking ... done. [1 of 2] Compiling EnableGUI ( EnableGUI.hs, interpreted ) [2 of 2] Compiling Main ( Main.hs, interpreted ) Ok, modules loaded: EnableGUI, Main. *Main> enableGUI >> main *Main> enableGUI >> main Bus error koshka:~/Desktop/TestWX doaitse$ So note that the first time the button appears, but the second time I =20= try to run it I get the bus error. This doesn't look good to me ;-{{, but I have no idea what to do next? The other unhealthy thing is that if I comment out the EnableGUI and =20 use ghc, I get: koshka:~/Desktop/TestWX doaitse$ ghc -package wx Main.hs koshka:~/Desktop/TestWX doaitse$ /usr/local/wxhaskell/bin/macosx-app -=20= v Main creating resource: > /Developer/Tools/Rez -t APPL Carbon.r -o Main creating app directories: - Main.app - Main.app/Contents - Main.app/Contents/MacOS - Main.app/Contents/Resources creating package info: - Main.app/Contents/PkgInfo done. koshka:~/Desktop/TestWX doaitse$ open Main 2007-02-16 13:38:46.947 open[1770] LSOpenFromURLSpec() returned =20 -10661 for application (null) urls file://localhost/Users/doaitse/=20 Desktop/TestWX/Main. koshka:~/Desktop/TestWX doaitse$ Anyone any ideas? Doaitse On Oct 22, 2006, at 4:18 PM, Mads Lindstr=F8m wrote: > Hi all > > Is there anybody who has an example of using context sensitive popup > menus? > > 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 > > > > ----------------------------------------------------------------------=20= > --- > Using Tomcat but need to do more? Need to support web services, =20 > security? > Get stuff done quickly with pre-integrated technology to make your =20 > job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache =20 > Geronimo > http://sel.as-us.falkag.net/sel?=20 > cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D121642 > _______________________________________________ > wxhaskell-users mailing list > wxh...@li... > https://lists.sourceforge.net/lists/listinfo/wxhaskell-users |
From: Doaitse S. <do...@cs...> - 2007-02-16 13:14:59
|
ad 1) It has been pointed out to me that you can call the enableGUI =20 >> main only once; otherwise you get the problem I had ad 2) I made a mistake in thinking that the a.out would always be =20 used. So bad reading of the instructions from my side. Sorry. Doaitse On Feb 16, 2007, at 1:40 PM, Doaitse Swierstra wrote: > When trying to run even the smallert wx program in my Mac OS X =20 > 10.4, Intel: > > module Main where > import Graphics.UI.WX > import EnableGUI > > main :: IO () > main > =3D start hello > > hello :: IO () > hello > =3D do f <- frame [text :=3D "Hello!"] > quit <- button f [text :=3D "Quit", on command :=3D close f] > set f [layout :=3D widget quit] > > I get: > > koshka:~/Desktop/TestWX doaitse$ ghci -package wx -fglasgow-exts =20 > Main.hs > ___ ___ _ > / _ \ /\ /\/ __(_) > / /_\// /_/ / / | | GHC Interactive, version 6.6, for Haskell =20= > 98. > / /_\\/ __ / /___| | http://www.haskell.org/ghc/ > \____/\/ /_/\____/|_| Type :? for help. > > Loading package base ... linking ... done. > Loading package haskell98 ... linking ... done. > Loading package wxcore-0.10.1 ... linking ... done. > Loading package wx-0.10.1 ... linking ... done. > [1 of 2] Compiling EnableGUI ( EnableGUI.hs, interpreted ) > [2 of 2] Compiling Main ( Main.hs, interpreted ) > Ok, modules loaded: EnableGUI, Main. > *Main> enableGUI >> main > *Main> enableGUI >> main > Bus error > koshka:~/Desktop/TestWX doaitse$ > > > So note that the first time the button appears, but the second time =20= > I try to run it I get the bus error. > > This doesn't look good to me ;-{{, but I have no idea what to do next? > > The other unhealthy thing is that if I comment out the EnableGUI =20 > and use ghc, I get: > > koshka:~/Desktop/TestWX doaitse$ ghc -package wx Main.hs > koshka:~/Desktop/TestWX doaitse$ /usr/local/wxhaskell/bin/macosx-=20 > app -v Main > creating resource: > > /Developer/Tools/Rez -t APPL Carbon.r -o Main > creating app directories: > - Main.app > - Main.app/Contents > - Main.app/Contents/MacOS > - Main.app/Contents/Resources > creating package info: > - Main.app/Contents/PkgInfo > done. > > koshka:~/Desktop/TestWX doaitse$ open Main > 2007-02-16 13:38:46.947 open[1770] LSOpenFromURLSpec() returned =20 > -10661 for application (null) urls file://localhost/Users/doaitse/=20 > Desktop/TestWX/Main. > koshka:~/Desktop/TestWX doaitse$ > > > Anyone any ideas? > > Doaitse > > > > > > On Oct 22, 2006, at 4:18 PM, Mads Lindstr=F8m wrote: > >> Hi all >> >> Is there anybody who has an example of using context sensitive popup >> menus? >> >> I am especially interested in an example with a listbox, where one =20= >> can >> right-click an element and get a popup menu. >> >> >> Greetings, >> >> Mads Lindstr=F8m >> >> >> >> ---------------------------------------------------------------------=20= >> ---- >> Using Tomcat but need to do more? Need to support web services, =20 >> security? >> Get stuff done quickly with pre-integrated technology to make your =20= >> job easier >> Download IBM WebSphere Application Server v.1.0.1 based on Apache =20 >> Geronimo >> http://sel.as-us.falkag.net/sel?=20 >> cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D121642 >> _______________________________________________ >> wxhaskell-users mailing list >> wxh...@li... >> https://lists.sourceforge.net/lists/listinfo/wxhaskell-users > > ----------------------------------------------------------------------=20= > --- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to =20 > share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?=20 > page=3Djoin.php&p=3Dsourceforge&CID=3DDEVDEV____________________________= ____=20 > _______________ > wxhaskell-users mailing list > wxh...@li... > https://lists.sourceforge.net/lists/listinfo/wxhaskell-users |