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