I am trying to use a DProperties panel in a project and I can get it to draw but I'm having problems retrieving the values.
[code]
panel.dProperties = vgui.Create("DProperties")
panel.dPropertiesCanvas = panel.dProperties:GetCanvas()
local Settings = panel.dProperties
local SettingsCanvas = panel.dPropertiesCanvas
Row1 = Settings:CreateRow( "View Settings", "Grid" )
Row1:Setup("custbool")
Row1:SetValue( false )
local Row2 = Settings:CreateRow( "View Settings", "Line Spacing Width" )
Row2:Setup("Int", {min=5, max=FrameW})
Row2:SetValue( 5 )
local Row3 = Settings:CreateRow( "View Settings", "Line Spacing Height" )
Row3:Setup("Int", {min=5, max=FrameH})
Row3:SetValue( 5 )
local Row4 = Settings:CreateRow( "Box Settings", "Box Size X (Percentage)" )
Row4:Setup("Int", {min=5, max=100})
Row4:SetValue( 75 )
local Row5 = Settings:CreateRow( "Box Settings", "Box Size Y (Percentage)" )
Row5:Setup("Int", {min=5, max=100})
Row5:SetValue( 75 )
local SettingsX = FrameX+FrameW
local SettingsY = FrameY
Settings:SetPos( SettingsX, SettingsY)
Settings:SetSize( (ScrW()*0.125), Frame:GetTall() )
SettingsCanvas:SetVisible(false)
[/code]
I had to make my own DProperties_Boolean type called "DProperties_custbool"
[code]
row_bool = {}
function row_bool:Init()
end
function row_bool:Setup()
self:Clear()
self.box = self:Add( "DCheckBox" )
local box = self.box
self.box:SetName("checkbox")
self.box:SetPos( 0, 2 )
-- Return true if we're editing
self.IsEditing = function( self )
return self.box:IsEditing()
end
-- Set the value
self.SetValue = function( self, val )
self.box:SetChecked( util.tobool( val ) )
end
-- Alert row that value changed
self.box.OnChange = function( box, newval )
if ( newval ) then newval = 1 else newval = 0 end
self:ValueChanged( newval )
panel.dProperties.Categories["View Settings"].Rows["Grid"].value = tobool(newval) --rigged here so i can do something
end
self.box.SGetValue = function()
return self.box:GetChecked()
end
end
derma.DefineControl( "DProperty_custbool", "", row_bool, "DProperty_Generic" )
[/code]
But I still can't figure out how to retrieve the value with both my custom bool, I can't find the checkbox to run SGetValue on, and I can't figure out how to retrieve the value on DProperty_Boolean
Sorry, you need to Log In to post a reply to this thread.