Garry's Mod Wiki

Revision Difference

DButton:DoRightClick#549919

<cat>panelfunc</cat> <function name="DoRightClick" parent="DButton" type="panelhook"> <description> Called when the button is right clicked (on key release) by the player. See also <page>DButton:DoClick</page>. </description> <realm>Client</realm>⤶ <realm>Client and Menu</realm>⤶ </function> <example> <description>Creates a 100 x 100 pixel button in the center of the screen, that prints `Hello World!` to the Chat and disappears when right clicked. </description> <code> local DermaButton = vgui.Create( "DButton" ) -- Creates our button DermaButton:SetText( "Click me!" ) DermaButton:SetSize( 100, 100 ) DermaButton:Center() DermaButton:SetMouseInputEnabled( true ) -- We must accept mouse input function DermaButton:DoRightClick() -- Defines what should happen when the label is clicked chat.AddText("Hello World!") self:Remove() end </code> <output> ``` Hello World! ``` When the button was right clicked.</output> </example>