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 flip_h: bool = false -
var flip_v: bool = false -
var ignore_texture_size: bool = false -
var stretch_mode = STRETCH_KEEP -
var texture_click_mask: BitMap -
var texture_disabled: Texture2D -
var texture_focused: Texture2D -
var texture_hover: Texture2D -
var texture_normal: Texture2D -
var texture_pressed: Texture2D -
const STRETCH_SCALE = 0 enum StretchMode -
const STRETCH_TILE = 1 enum StretchMode -
const STRETCH_KEEP = 2 enum StretchMode -
const STRETCH_KEEP_CENTERED = 3 enum StretchMode -
const STRETCH_KEEP_ASPECT = 4 enum StretchMode -
const STRETCH_KEEP_ASPECT_CENTERED = 5 enum StretchMode -
const STRETCH_KEEP_ASPECT_COVERED = 6 enum StretchMode -
enum StretchMode
TextureButton #
is_instantiable, Node, core, not_builtin_classes
Texture-based button. Supports Pressed, Hover, Disabled and Focused states.
TextureButton has the same functionality as Button, except it uses sprites instead of Godot's Theme resource. It is faster to create, but it doesn't support localization like more complex Controls.
See also BaseButton which contains common properties and methods associated with this node.
Note: Setting a texture for the "normal" state (texture_normal) is recommended. If texture_normal is not set, the TextureButton will still receive input events and be clickable, but the user will not be able to see it unless they activate another one of its states with a texture assigned (e.g., hover over it to show texture_hover).
Members #
var flip_h: bool = false#
If true, texture is flipped horizontally.
var flip_v: bool = false#
If true, texture is flipped vertically.
var ignore_texture_size: bool = false#
If true, the size of the texture won't be considered for minimum size calculation, so the TextureButton can be shrunk down past the texture size.
var stretch_mode = STRETCH_KEEP#
Controls the texture's behavior when you resize the node's bounding rectangle. See the StretchMode constants for available options.
var texture_click_mask: BitMap#
Pure black and white BitMap image to use for click detection. On the mask, white pixels represent the button's clickable area. Use it to create buttons with curved shapes.
var texture_disabled: Texture2D#
Texture to display when the node is disabled. See BaseButton.disabled. If not assigned, the TextureButton displays texture_normal instead.
var texture_focused: Texture2D#
Texture to overlay on the base texture when the node has mouse or keyboard focus. Because texture_focused is displayed on top of the base texture, a partially transparent texture should be used to ensure the base texture remains visible. A texture that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a fully transparent texture of any size. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.
var texture_hover: Texture2D#
Texture to display when the mouse hovers over the node. If not assigned, the TextureButton displays texture_normal instead when hovered over.
var texture_normal: Texture2D#
Texture to display by default, when the node is not in the disabled, hover or pressed state. This texture is still displayed in the focused state, with texture_focused drawn on top.
var texture_pressed: Texture2D#
Texture to display on mouse down over the node, if the node has keyboard focus and the player presses the Enter key or if the player presses the BaseButton.shortcut key. If not assigned, the TextureButton displays texture_hover instead when pressed.
Methods #
Annotations #
Constants #
const STRETCH_SCALE = 0 enum StretchMode#
Scale to fit the node's bounding rectangle.
const STRETCH_TILE = 1 enum StretchMode#
Tile inside the node's bounding rectangle.
const STRETCH_KEEP = 2 enum StretchMode#
The texture keeps its original size and stays in the bounding rectangle's top-left corner.
const STRETCH_KEEP_CENTERED = 3 enum StretchMode#
The texture keeps its original size and stays centered in the node's bounding rectangle.
const STRETCH_KEEP_ASPECT = 4 enum StretchMode#
Scale the texture to fit the node's bounding rectangle, but maintain the texture's aspect ratio.
const STRETCH_KEEP_ASPECT_CENTERED = 5 enum StretchMode#
Scale the texture to fit the node's bounding rectangle, center it, and maintain its aspect ratio.
const STRETCH_KEEP_ASPECT_COVERED = 6 enum StretchMode#
Scale the texture so that the shorter side fits the bounding rectangle. The other side clips to the node's limits.
Constructors #
Enums #
StretchMode#
enum StretchMode {
STRETCH_SCALE = 0,
STRETCH_TILE = 1,
STRETCH_KEEP = 2,
STRETCH_KEEP_CENTERED = 3,
STRETCH_KEEP_ASPECT = 4,
STRETCH_KEEP_ASPECT_CENTERED = 5,
STRETCH_KEEP_ASPECT_COVERED = 6,
}