fork/m-overlay
git clone https://git.julia.blue/fork/m-overlay
a8034e9
v2.1.1
1local PANEL =class . create ( "ContextMenu" , "Panel" ) 2 3function PANEL : ContextMenu () 4self : super () -- Initialize our baseclass 5 6self . m_tEntries ={} 7 8self : DockPadding ( 0 , 0 , 0 , 0 ) 9 10self : SetWidth ( 128 + 32 ) 11self : MakePopup () 12end 13 14function PANEL : OnFocusChanged ( b ) 15-- Remove on focus lost 16if not b then self : Remove () end 17end 18 19function PANEL : PerformLayout () 20self : SizeToChildren ( false , true ) 21end 22 23function PANEL : AddSeperator ( height ) 24local entry =self : Add ( "Panel" ) 25entry : SetHeight ( height or 4 ) 26entry : SetBGColor ( color_blank ) 27entry : SetBorderColor ( color_blank ) 28entry : DockMargin ( 0 , 0 , 0 , 0 ) 29entry : Dock ( DOCK_TOP ) 30end 31 32function PANEL : AddEntry ( name , callback ) 33local entry =self : Add ( "Button" ) 34entry : SetText ( name ) 35entry : SetBGColor ( color_blank ) 36entry : SetBorderColor ( color_blank ) 37entry : DockMargin ( 0 , 0 , 0 , 0 ) 38entry : Dock ( DOCK_TOP ) 39 40self . m_tEntries [ name ] =callback 41 42entry . OnClick =function ( this ) 43self : OnEntryClicked ( name , this ) 44if self . m_tEntries [ name ] then 45self . m_tEntries [ name ]( panel ) 46end 47end 48 49return entry 50end 51 52function PANEL : OnEntryClicked ( name , panel ) 53end