|
|
|
|
#1 |
![]() Join Date: Aug 2007
Reputation: 9
Posts: 555
|
VGUI usage questions
![]() I am attempting to have one checkbutton disable the other when it is checked. I know how to control each element in my panel.cpp: Code:
///Constructor of my panel m_pTime = new vgui::CheckButton(this, "Check1", "Test"); m_pTime->SetPos(100, 400); m_pTime->SetSize(200, 50); m_pTime2 = new vgui::CheckButton(this, "Check2", "Test2"); m_pTime2->SetPos(100, 600); m_pTime2->SetSize(200, 50); m_pTime2->SetEnabled(false); But how to I call SetEnabled for a checkbutton based on interaction with another element? I found this function in checkbutton.cpp which looks useful: Code:
void CheckButton::OnCheckButtonChecked(Panel *panel)
{
}
|
|
|
|
|
|
#2 |
![]() Join Date: Aug 2007
Reputation: 9
Posts: 555
|
Investigated a bit more and found OnMousePressed in the Panel class. When I want to call it in Checkbutton it says ERROR: inherited member is not allowed
Code:
void CheckButton::OnMousePressed(MouseCode code)
{
}
Checkbutton should inherit all public functions from panel or am I not getting something? |
|
|
|
|
|
#3 |
![]() Join Date: Aug 2007
Reputation: 9
Posts: 555
|
After more research I got this far:
In my panel class Code:
private: //Other used VGUI control Elements: vgui::CheckButton* m_pTime; // Panel class declaration, private section vgui::CheckButton* m_pTime2; vgui::Button *exitbutton; public: MESSAGE_FUNC_PARAMS( OnCheck1Checked, "CheckButtonChecked", data ); Code:
MESSAGE_FUNC_PARAMS( OnCheck1Checked, "CheckButtonChecked", data ); Code:
void CMyPanel::OnCheck1Checked( KeyValues *data )
{
//check which checkbutton pointer is used so that it can fire different things depending on which checkbutton was checked.
}
|
|
|
|
|
|
#4 |
![]() Join Date: Jun 2009
Reputation: 34
Posts: 86
|
CheckButtonList.cpp contains an example on how to use that message function.
You can get the checkbutton from the panel parameter: Code:
vgui::Panel *pPanel = (vgui::Panel *)data->GetPtr( "panel" ); |
|
|
|
|
|
#5 |
![]() Join Date: Aug 2007
Reputation: 9
Posts: 555
|
Using it as is crashes the game in the main menu which I think is a broken pointer.
Code:
void CMyPanel::OnCheck1Checked( KeyValues *data )
{
vgui::Panel *pPanel = (vgui::Panel *)data->GetPtr( "panel" );
if ( FStrEq( pPanel->GetName(), "Check1" ) )
{
Msg("Name is check1\n");
}
else
{
Msg("Name is not check1\n");
}
}
|
|
|
|
|
|
#6 |
![]() Join Date: Aug 2007
Reputation: 9
Posts: 555
|
Fixed the problem after reading the VGUI documentation closely, a few times.
https://developer.valvesoftware.com/..._Documentation Another problem I have is that I want to create a CModelPanel. However the compiler says: error C2039: 'CModelPanel' : is not a member of 'vgui' The problem has to be a missing include or something. Class declaration my panel Code:
private: //Other used VGUI control Elements: vgui::CheckButton* m_pTime; // Panel class declaration, private section vgui::CheckButton* m_pTime2; vgui::Button *exitbutton; vgui::ComboBox *calibercombo; vgui::CModelPanel *bulletpanel; |
|
|
|
|
|
#7 |
![]() Join Date: Aug 2007
Reputation: 9
Posts: 555
|
Again ran into this error:
ERROR: inherited member is not allowed In my panel Code:
void CMyPanel::ApplySchemeSettings(IScheme *pScheme)
{
BaseClass::ApplySchemeSettings(pScheme);
pScheme->GetFont( "Trebuchet18" );
}
Code:
class MyPanel
{
public:
virtual void Create( vgui::VPANEL parent ) = 0;
virtual void Destroy( void ) = 0;
protected:
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
};
|
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|