Yes I am making my own, I do not know what you mean by using the OS menu system.
Code: Select all
@DISPLAY 1,{x= 200,Y=200,Width =800,Height =600,Color = $999999}
SetFont("Ruby",12)
SetFontColor(#BLACK)
Line (1,23,800,23,#BLACK)
Box (30,30,400,30,#WHITE)
Global MP,MT,MTW,MC,MS,MM
Global ML,ML0,ML1,ML2,ML3
Function Menus() ;---------------------------------------------------------------------------------
MenuItems = 4
MenuTitle = {" File "," Drawing Shapes "," Program Help "," About "}
Menu0 = {" Open "," Save "," Close "}
Menu1 = {" Square "," Circle "," Triangle "," Box "}
Menu2 = {" Help "}
Menu3 = {" About "}
For t = 0 to ListItems(Menu0)-1
Length = TextWidth(Menu0[t])
If Length > ML0
ML0 = Length
EndIf
Next
For t = 0 to ListItems(Menu1)-1
Length = TextWidth(Menu1[t])
If Length > ML1
ML1 = Length
EndIf
Next
For t = 0 to ListItems(Menu2)-1
Length = TextWidth(Menu2[t])
If Length > ML2
ML2 = Length
EndIf
Next
For t = 0 to ListItems(Menu3)-1
Length = TextWidth(Menu3[t])
If Length > ML3
ML3 = Length
EndIf
Next
MenuPos = {}
MenuPosition = 2
InsertItem(MenuPos,2)
For t = 1 to MenuItems
MakeButton(t,#SIMPLEBUTTON,MenuPosition,1,TextWidth(MenuTitle[t-1]),20,{OnMouseDown = MenuFunc,OnMouseOver = MenuFunc,OnMouseOut = MenuFunc,OnMouseUp = MenuFunc})
TextOut(MenuPosition,5,MenuTitle[t-1])
MenuPosition = MenuPosition + TextWidth(MenuTitle[t-1])
InsertItem(MenuPos,MenuPosition)
Next
EndFunction
Function MenuFunc(msg) ; --------------------------------------------------------------------------
Switch msg.action
Case "OnMouseDown":
MakeMenu()
Case "OnMouseOut":
HighLightMenuOff(msg)
Case "OnMouseOver"
HighLightMenu(msg)
Case "OnMouseUp":
BreakMenu()
EndSwitch
EndFunction
Function p_MyFunc(msg) ;---------------------------------------------------------------------------
Switch msg.action
Case "OnMouseDown":
ShowMenu(msg)
Case "OnMouseOut":
BreakMenu(msg)
Case "OnMouseUp":
SelectMenu(msg)
EndSwitch
EndFunction
Function HighlightMenu(msg) ;----------------------------------------------------------------------
Switch msg.id
Case 1:
Menu = CopyTable(Menu0)
MS = ListItems(Menu0)
MP = MenuPos[0]
MT = MenuTitle[0]
MTW = TextWidth(MenuTitle[0])
MC = $888888
ML = ML0
MM = 0
MenuHighLight()
Case 2:
Menu = CopyTable(Menu1)
MS = ListItems(Menu1)
MP = MenuPos[1]
MT = MenuTitle[1]
MTW = TextWidth(MenuTitle[1])
MC = $888888
ML = ML1
MM = 3
MenuHighLight()
Case 3:
Menu = CopyTable(Menu2)
MS = ListItems(Menu2)
MP = MenuPos[2]
MT = MenuTitle[2]
MTW = TextWidth(MenuTitle[2])
MC = $888888
ML = ML2
MM = 7
MenuHighLight()
Case 4:
Menu = CopyTable(Menu3)
MS = ListItems(Menu3)
MP = MenuPos[3]
MT = MenuTitle[3]
MTW = TextWidth(MenuTitle[3])
MC = $888888
ML = ML3
MM = 8
MenuHighLight()
EndSwitch
EndFunction
Function HighlightMenuOff(msg) ;-------------------------------------------------------------------
Switch msg.id
Case 1:
Menu = CopyTable(Menu0)
MP = MenuPos[0]
MT = MenuTitle[0]
MTW = TextWidth(MenuTitle[0])
MC = $999999
If MM <> 0
BreakMenu()
EndIf
MenuHighLight()
Case 2:
Menu = CopyTable(Menu1)
MP = MenuPos[1]
MT = MenuTitle[1]
MTW = TextWidth(MenuTitle[1])
MC = $999999
If MM <> 3
BreakMenu()
EndIf
MenuHighLight()
Case 3:
Menu = CopyTable(Menu2)
MP = MenuPos[2]
MT = MenuTitle[2]
MTW = TextWidth(MenuTitle[2])
MC = $999999
If MM <> 7
BreakMenu()
EndIf
MenuHighLight()
Case 4:
Menu = CopyTable(Menu3)
MP = MenuPos[3]
MT = MenuTitle[3]
MTW = TextWidth(MenuTitle[3])
MC = $999999
If MM <> 8
BreakMenu()
EndIf
MenuHighLight()
EndSwitch
EndFunction
Function MenuHighLight() ; -----------------------------------------------
SetFillStyle(#FILLCOLOR)
Box(MP,1,MTW,20,MC)
SetFontColor(#BLACK)
TextOut(MP,5,MT)
EndFunction
Function MakeMenu() ; ----------------------------------------------------
Box(MP,26,ML,(20*MS)+1,$888888)
MakeButton(MenuItems+1,#SIMPLEBUTTON,MP,26,ML,(20*MS)+1,{OnMouseOver = p_MyFunc,OnMouseOut = p_MyFunc,OnMouseUp = p_MyFunc,OnMouseDown = p_MyFunc})
For t = 0 to MS-1
TextOut(MP+2,29+(t*20),Menu[t])
Next
EndFunction
Function BreakMenu() ; ----------------------------------------------------
Box(MP,26,ML,(20*MS)+1,$999999)
DeleteButton(MenuItems+1)
EndFunction
Function ShowMenu() ; -----------------------------------------------------------------------------
Local MPosY = MouseY()
MPosY = Int((MposY-29)/20)
Box(MP,26,ML,(20*MS)+1,$888888)
Box(MP+1,26+(MPosy*20),ML-2,20,$AAAAAA)
For t = 0 to MS-1
TextOut(MP+2,29+(t*20),Menu[t])
Next
EndFunction
Function SelectMenu() ;----------------------------------------------------------------------------
Local MPosY = MouseY()
If MM+Int((MPosY-29)/20) = 0
Selected0()
ElseIf MM+Int((MPosY-29)/20) = 1
Selected1()
ElseIf MM+Int((MPosY-29)/20) = 2
Selected2()
ElseIf MM+Int((MPosY-29)/20) = 3
Selected3()
ElseIf MM+Int((MPosY-29)/20) = 4
Selected4()
ElseIf MM+Int((MPosY-29)/20) = 5
Selected5()
ElseIf MM+Int((MPosY-29)/20) = 6
Selected6()
ElseIf MM+Int((MPosY-29)/20) = 7
Selected7()
ElseIf MM+Int((MPosY-29)/20) = 8
Selected8()
EndIf
EndFunction
Function Selected0()
Box(100,250,150,40,$999999)
TextOut(100,250,"Selection 0")
EndFunction
Function Selected1()
Box(100,250,150,40,$999999)
TextOut(100,250,"Selection 1")
EndFunction
Function Selected2()
Box(100,250,150,40,$999999)
TextOut(100,250,"Selection 2")
EndFunction
Function Selected3()
Box(100,250,150,40,$999999)
TextOut(100,250,"Selection 3")
EndFunction
Function Selected4()
Box(100,250,150,40,$999999)
TextOut(100,250,"Selection 4")
EndFunction
Function Selected5()
Box(100,250,150,40,$999999)
TextOut(100,250,"Selection 5")
EndFunction
Function Selected6()
Box(100,250,150,40,$999999)
TextOut(100,250,"Selection 6")
EndFunction
Function Selected7()
Box(100,250,150,40,$999999)
TextOut(100,250,"Selection 7")
EndFunction
Function Selected8()
Box(100,250,150,40,$999999)
TextOut(100,250,"Selection 8")
EndFunction
; Allow quit with ESC at any time! ****************************************************************
EscapeQuit(True)
;
Menus()
;
; Main loop!
;
Repeat
WaitEvent
Forever
The code above is what I could remember as I am at work now,but it does the same thing.
Once the menu is drawn it destroys the white box, is there a way to have the menu on its own layer so what is under it does not get destroyed?