resize gadget in container
BlitzMax Forums/BlitzMax Beginners Area/resize gadget in container
| ||
| Hi I create a panel as container , I put a button in it it's work if I resize the window I resize at the same time the panel but my button move too, it's there a way to reposition the button at the same place where it use to be? here my code
Strict
Global window:TGadget
Global panel:TGadget
Global button1:TGadget
Global Popup_Menu:TGadget
Global gadgetlist:TList=New TList
window=CreateWindow("My Window",40,40,320,240,Null,WINDOW_TITLEBAR|EVENT_WINDOWSIZE|WINDOW_STATUS)
panel=CreatePanel(0,0,ClientWidth(window),ClientHeight(window),window,PANEL_ACTIVE)
button1 = CreateButton("Button",0,0,64,24,panel)
'Add the button to the gadget list
gadgetlist.AddLast button1
'Add our hook to the system
AddHook EmitEventHook,MyEventHook
'The main loop and the others event
While True
WaitEvent
Select CurrentEvent.ID
Case EVENT_MOUSEENTER
SetGadgetText button1,"Button"
SetStatusText window,"Mouse in main window area"
Case EVENT_MOUSELEAVE
Select MouseOverGadget()
Case button1
SetGadgetText button1,"mouseover"
SetStatusText window,"Mouse over button"
End Select
Case EVENT_MOUSEDOWN
End Select
Wend
'Hooks mouse event
Function MyEventHook:Object( id,data:Object,context:Object )
Local ev:TEvent=TEvent(data)
Select ev.id
Case EVENT_WINDOWCLOSE
End
Case EVENT_MOUSEDOWN
If ev.data = Mouse_Right
PopupUP()
If Popup_Menu<>Null PopupWindowMenu(window,popup_menu)
EndIf
' EndIf
Case EVENT_WINDOWSIZE
SetGadgetShape(panel,0,0,ClientWidth(window),ClientHeight(window))
'even if I resize the panel, the button in it does't
'resize at the same place where it should be.
'Try resizing the window you will see.
End Select
Return data
End Function
'Detect if the mouse is over a gadget Ie:this is not my routine
Function MouseOverGadget:TGadget()
Local mx=CurrentEvent.x
Local my=CurrentEvent.y
For Local g:TGadget=EachIn gadgetlist
If mx>=g.xpos And mx<g.xpos+g.width
If my>=g.ypos And my<g.ypos+g.height
Return g
EndIf
EndIf
Next
Return Null
End Function
'Create the popup
Function PopupUP()
Popup_Menu=CreateMenu("Quick Help",125,panel)
CreateMenu "Copy",126,popup_menu,KEY_N,MODIFIER_COMMAND
CreateMenu "Past",127,popup_menu,KEY_N,MODIFIER_COMMAND
End Function
also, the popup does't work over the button because the mouse leave the panel.... Do I need to create a new popup when mouse get over each gadget? |