PopupWindowMenu

BlitzMax Forums/BlitzMax Beginners Area/PopupWindowMenu

Smokey(Posted 2005) [#1]
Hi

I tried to do a popup window and I don't get it
someone have working example?


Takuan(Posted 2005) [#2]
[Codebox]
Type TApplet

Field window:TGadget
Field canvas:TGadget
Field timer:TTimer

Field Popup_Gadget:TGadget
Field Popup_Menu:TGadget

Method Render()
Local x,y,width,height,t,i
width=GraphicsWidth()
height=GraphicsHeight()
t=MilliSecs()
SetBlend ALPHABLEND
SetViewport 0,0,width,height
SetClsColor 0,0,0
SetOrigin width/2,height/2
Cls
For x=-width/2 To width/2 Step 2
y=Sin(t*0.3+x)*height/2
DrawLine 0,0,x,y
Next
End Method

Method OnEvent(event:TEvent)
Select event.id
Case EVENT_WINDOWCLOSE
End
Case EVENT_TIMERTICK
RedrawGadget canvas
Case EVENT_GADGETPAINT
SetGraphics CanvasGraphics(canvas)
Render
Flip


'POP UP
Case Event_Mousedown
Select event.data
Case Mouse_Right
If Popup_Menu<>Null PopupWindowMenu(window,popup_menu)
End Select
End Select
End Method

Function eventhook:Object(id,data:Object,context:Object)
Local event:TEvent
Local app:TApplet
event=TEvent(data)
app=TApplet(context)
app.OnEvent event
End Function

Method Create:TApplet(name$)

Popup_Menu=CreateMenu("Dummy",Dummy,Popup_Gadget)
CreateMenu "Cat",Dummy2,popup_menu,KEY_N,MODIFIER_COMMAND
CreateMenu "Dog",Dummy3,popup_menu,KEY_N,MODIFIER_COMMAND




Local a:TApplet
Local w,h
window=CreateWindow(name,20,20,512,512)
window.SetTarget Self
w=ClientWidth(window)
h=ClientHeight(window)
canvas=CreateCanvas(0,0,w,h,window)
canvas.SetLayout 1,1,1,1
canvas.SetTarget Self
timer=CreateTimer(100)
AddHook EmitEventHook,eventhook,Self
Return Self
End Method

End Type

AutoMidHandle True

Local applet:TApplet

applet=New TApplet.Create("Render Applet")

While True
WaitEvent
Wend
[/Codebox]

One day i will figure out how to use Codebox...


WendellM(Posted 2005) [#3]
One day i will figure out how to use Codebox...

Your brackets are fine, but "codebox" and "/codebox" need to be all lowercase.

And that's a very pretty-looking popup menu demo. :)


Smokey(Posted 2005) [#4]
it's there something more simple to do a popup do we really need to use eventhook ?


Takuan(Posted 2005) [#5]
Dont think you have to, but i would realy recommend it, if you want to use things like menu's which would draw over the canvas (encountered graphic problems while not using event hook rendering...check out MaxGUI Overview).

@Wendel
The code was from the example in MaxGUI Overview, i just added the popup;)