News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Flexi Menu

Started by kevin, August 08, 2007, 02:53:16 AM

Previous topic - Next topic

kevin

  Here's a bit of menu example, I was throwing together for the re-release of TwinTrix.   Pretty simple,  you just add the nodes with their parents and it does the rest for you.   When you click on node it returns the HANDLE. 

The setup/ react code looks like this.  Will post the complete library when it's done.




LoadFont "Arial",2,16,0


InitMenu(0,2,Rgb(80,100,100),Rgb(255,255,255),Rgb(100,200,0))


ParentID$=""
AddMenuItem("FILE",ParentID$,"FILE")
AddMenuItem("EDIT",ParentID$,"EDIT")
AddMenuItem("ABOUT",ParentID$,"ABOUT")


; File Menu
ParentID$="FILE"
AddMenuItem("FILENEW",ParentID$,"New")
AddMenuItem("FILEDIV",ParentID$,"-")
AddMenuItem("FILELOAD",ParentID$,"Load")
AddMenuItem("FILESAVE",ParentID$,"Save")
AddMenuItem("FILEDIV",ParentID$,"-")
AddMenuItem("FILEHISTORY",ParentID$,"History")
AddMenuItem("FILEDIV",ParentID$,"-")
AddMenuItem("FILEQUIT",ParentID$,"Quit")


; Histroy Sub Memu
ParentID$="FILEHISTORY"

AddMenuItem("FILE1",ParentID$,"File1")
AddMenuItem("FILE2",ParentID$,"File2")
AddMenuItem("FILE3",ParentID$,"File3")
AddMenuItem("FILE4",ParentID$,"File4")
AddMenuItem("FILE5",ParentID$,"File5")



; Edit Menu
ParentID$="EDIT"
AddMenuItem("EDITCUT",ParentID$,"Cut")
AddMenuItem("EDITPASTE",ParentID$,"Paste")
AddMenuItem("EDITDELETE",ParentID$,"Delete")



; About Menu
ParentID$="ABOUT"
AddMenuItem("ABOUTHOMEPAGE",ParentID$,"HomePage")
AddMenuItem("ABOUTME",ParentID$,"About")



Setfps 75


Do

Cls rgb(55,30,50)

mx=mousex()
my=mousey()
mb=mousebutton()


DrawMenu(FlexiMenu(),mx,my,mb)

; --------------------------------
ClickedMenuGadget$=GetClickedMenuItem()
Select ClickedMenuGadget$
case "FILELOAD"
                                                        ;load file
                  case "FILESAVE"
                                                        ;save file
case "FILEQUIT"
end


case "FILE1","FILE2","FILE3"
#print "File history"+ClickedMenuGadget$

EndSelect

Sync
loop







Draco9898

DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin


Flexi Menu

     Been working on this a little more tonight, previously it was rendering but you couldn't really select anything.  So now you can init the menu, render it and catch the clicked events from the menu refresh.  Works much like the standard menus you see on every windows app,  expect that it's only visible when when you've hover over that region of the screen or click upon it.

    The screen shot is basically the same at the one above but showing that it's menus can be nested.   

SpellSword

When I dream,
I carry a sword in one hand,
a gun in the other...