You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
465 B
17 lines
465 B
[Tool] |
|
public partial class ModifierToggleButton : Button |
|
{ |
|
[Export] public Texture2D OnTexture { get; set; } |
|
[Export] public Texture2D OffTexture { get; set; } |
|
[Export] public Key ModifierKey { get; set; } |
|
|
|
|
|
public override void _Ready() |
|
=> Toggled += (on) => Icon = on ? OnTexture : OffTexture; |
|
|
|
public override void _Input(InputEvent ev) |
|
{ |
|
if ((ev is InputEventKey { Keycode: var key }) && (key == ModifierKey)) |
|
ButtonPressed = !ButtonPressed; |
|
} |
|
}
|
|
|