Inheritance #
- AudioServer
- CameraServer
- ClassDB
- DisplayServer
- EditorFileSystemDirectory
- EditorInterface
- EditorPaths
- EditorSelection
- EditorUndoRedoManager
- EditorVCSInterface
- Engine
- EngineDebugger
- FramebufferCacheRD
- GDExtensionManager
- Geometry2D
- Geometry3D
- IP
- Input
- InputMap
- JNISingleton
- JSONRPC
- JavaClassWrapper
- JavaScriptBridge
- MainLoop (1)
- Marshalls
- MovieWriter
- NativeMenu
- NavigationMeshGenerator
- NavigationServer2D
- NavigationServer3D
- Node (21)
- OS
- OpenXRExtensionWrapperExtension
- OpenXRInteractionProfileMetadata
- Performance
- PhysicsDirectBodyState2D (1)
- PhysicsDirectBodyState3D (1)
- PhysicsDirectSpaceState2D (1)
- PhysicsDirectSpaceState3D (1)
- PhysicsServer2D (1)
- PhysicsServer2DManager
- PhysicsServer3D (1)
- PhysicsServer3DManager
- PhysicsServer3DRendering
ServerHandler
- ProjectSettings
- RefCounted (121)
- RenderData (2)
- RenderSceneData (2)
- RenderingDevice
- RenderingServer
- ResourceLoader
- ResourceSaver
- ResourceUID
- ScriptLanguage (1)
- ShaderIncludeDB
- TextServerManager
- ThemeDB
- TileData
- Time
- TranslationServer
- TreeItem
- UndoRedo
- UniformSetCacheRD
- WorkerThreadPool
- XRServer
- XRVRS
- AnimationMixer (2)
- AudioStreamPlayer
- CanvasItem (2)
- CanvasLayer (1)
- EditorFileSystem
- EditorPlugin (1)
- EditorResourcePreview
- HTTPRequest
- InstancePlaceholder
- MissingNode
- MultiplayerSpawner
- MultiplayerSynchronizer
- NavigationAgent2D
- NavigationAgent3D
- Node3D (31)
- ResourcePreloader
- ShaderGlobalsOverride
- StatusIndicator
- Timer
- Viewport (2)
- WorldEnvironment
- BaseButton (3)
- ColorRect
- Container (13)
- GraphEdit
- ItemList
- Label
- LineEdit
- MenuBar
- NinePatchRect
- Panel
- Range (6)
- ReferenceRect
- RichTextLabel
- Separator (2)
- TabBar
- TextEdit (1)
- TextureRect
- Tree
- VideoStreamPlayer
Table of contents
-
var action_mode = ACTION_MODE_BUTTON_RELEASE -
var button_group: ButtonGroup -
var button_mask: int = 1 -
var button_pressed: bool = false -
var disabled: bool = false -
var focus_mode = FOCUS_ALL -
var keep_pressed_outside: bool = false -
var shortcut: Shortcut -
var shortcut_feedback: bool = true -
var shortcut_in_tooltip: bool = true -
var toggle_mode: bool = false -
virtual func _pressed() -> void -
virtual func _toggled(toggled_on: bool) -> void -
const func get_draw_mode() -> intBaseButton.DrawMode -
const func is_hovered() -> bool -
func set_pressed_no_signal(pressed: bool) -> void -
const DRAW_NORMAL = 0 enum DrawMode -
const DRAW_PRESSED = 1 enum DrawMode -
const DRAW_HOVER = 2 enum DrawMode -
const DRAW_DISABLED = 3 enum DrawMode -
const DRAW_HOVER_PRESSED = 4 enum DrawMode -
const ACTION_MODE_BUTTON_PRESS = 0 enum ActionMode -
const ACTION_MODE_BUTTON_RELEASE = 1 enum ActionMode -
enum DrawMode -
enum ActionMode -
signal button_down() -
signal button_up() -
signal pressed() -
signal toggled(toggled_on: bool)
BaseButton #
is_instantiable, Node, core, not_builtin_classes
Abstract base class for GUI buttons.
BaseButton is an abstract base class for GUI buttons. It doesn't display anything by itself.
Members #
var action_mode = ACTION_MODE_BUTTON_RELEASE#
Determines when the button is considered clicked, one of the ActionMode constants.
var button_group: ButtonGroup#
The ButtonGroup associated with the button. Not to be confused with node groups.
Note: The button will be configured as a radio button if a ButtonGroup is assigned to it.
var button_mask: int = 1#
Binary mask to choose which mouse buttons this button will respond to.
To allow both left-click and right-click, use MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT.
var button_pressed: bool = false#
If true, the button's state is pressed. Means the button is pressed down or toggled (if toggle_mode is active). Only works if toggle_mode is true.
Note: Changing the value of button_pressed will result in toggled to be emitted. If you want to change the pressed state without emitting that signal, use set_pressed_no_signal.
var disabled: bool = false#
If true, the button is in disabled state and can't be clicked or toggled.
var focus_mode = FOCUS_ALL#
var keep_pressed_outside: bool = false#
If true, the button stays pressed when moving the cursor outside the button while pressing it.
Note: This property only affects the button's visual appearance. Signals will be emitted at the same moment regardless of this property's value.
var shortcut: Shortcut#
Shortcut associated to the button.
var shortcut_feedback: bool = true#
If true, the button will highlight for a short amount of time when its shortcut is activated. If false and toggle_mode is false, the shortcut will activate without any visual feedback.
var shortcut_in_tooltip: bool = true#
If true, the button will add information about its shortcut in the tooltip.
Note: This property does nothing when the tooltip control is customized using Control._make_custom_tooltip.
var toggle_mode: bool = false#
If true, the button is in toggle mode. Makes the button flip state between pressed and unpressed each time its area is clicked.
Methods #
virtual func _pressed() -> void#
Called when the button is pressed. If you need to know the button's pressed state (and toggle_mode is active), use _toggled instead.
virtual func _toggled(toggled_on: bool) -> void#
Called when the button is toggled (only if toggle_mode is active).
const func get_draw_mode() -> intBaseButton.DrawMode#
Returns the visual state used to draw the button. This is useful mainly when implementing your own draw code by either overriding _draw() or connecting to "draw" signal. The visual state of the button is defined by the DrawMode enum.
const func is_hovered() -> bool#
Returns true if the mouse has entered the button and has not left it yet.
func set_pressed_no_signal(pressed: bool) -> void#
Changes the button_pressed state of the button, without emitting toggled. Use when you just want to change the state of the button without sending the pressed event (e.g. when initializing scene). Only works if toggle_mode is true.
Note: This method doesn't unpress other buttons in button_group.
Annotations #
Constants #
const DRAW_NORMAL = 0 enum DrawMode#
The normal state (i.e. not pressed, not hovered, not toggled and enabled) of buttons.
const DRAW_PRESSED = 1 enum DrawMode#
The state of buttons are pressed.
const DRAW_HOVER = 2 enum DrawMode#
The state of buttons are hovered.
const DRAW_DISABLED = 3 enum DrawMode#
The state of buttons are disabled.
const DRAW_HOVER_PRESSED = 4 enum DrawMode#
The state of buttons are both hovered and pressed.
const ACTION_MODE_BUTTON_PRESS = 0 enum ActionMode#
Require just a press to consider the button clicked.
const ACTION_MODE_BUTTON_RELEASE = 1 enum ActionMode#
Require a press and a subsequent release before considering the button clicked.
Constructors #
Enums #
DrawMode#
enum DrawMode {
DRAW_NORMAL = 0,
DRAW_PRESSED = 1,
DRAW_HOVER = 2,
DRAW_DISABLED = 3,
DRAW_HOVER_PRESSED = 4,
}ActionMode#
enum ActionMode {
ACTION_MODE_BUTTON_PRESS = 0,
ACTION_MODE_BUTTON_RELEASE = 1,
} Operators #
Signals #
signal button_down()#
Emitted when the button starts being held down.
signal button_up()#
Emitted when the button stops being held down.
signal pressed()#
Emitted when the button is toggled or pressed. This is on button_down if action_mode is ACTION_MODE_BUTTON_PRESS and on button_up otherwise.
If you need to know the button's pressed state (and toggle_mode is active), use toggled instead.
signal toggled(toggled_on: bool)#
Emitted when the button was just toggled between pressed and normal states (only if toggle_mode is active). The new state is contained in the toggled_on argument.