Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

LinkButton

繼承: BaseButton < Control < CanvasItem < Node < Object

代表連結的按鈕。

說明

代表連結的按鈕。這種按鈕主要用於與按鈕的互動引起本文變化時(如連結到網頁)。

另見 BaseButton,它包含了該節點相關的常用屬性和方法。

屬性

String

ellipsis_char

"…"

FocusMode

focus_mode

3 (overrides Control)

String

language

""

CursorShape

mouse_default_cursor_shape

2 (overrides Control)

StructuredTextParser

structured_text_bidi_override

0

Array

structured_text_bidi_override_options

[]

String

text

""

TextDirection

text_direction

0

OverrunBehavior

text_overrun_behavior

0

UnderlineMode

underline

0

String

uri

""

主題屬性

Color

font_color

Color(0.875, 0.875, 0.875, 1)

Color

font_disabled_color

Color(0, 0, 0, 1)

Color

font_focus_color

Color(0.95, 0.95, 0.95, 1)

Color

font_hover_color

Color(0.95, 0.95, 0.95, 1)

Color

font_hover_pressed_color

Color(0, 0, 0, 1)

Color

font_outline_color

Color(0, 0, 0, 1)

Color

font_pressed_color

Color(1, 1, 1, 1)

int

outline_size

0

int

underline_spacing

2

Font

font

int

font_size

StyleBox

focus


列舉

enum UnderlineMode: 🔗

UnderlineMode UNDERLINE_MODE_ALWAYS = 0

LinkButton 將始終在其文字底部顯示底線。

UnderlineMode UNDERLINE_MODE_ON_HOVER = 1

LinkButton 將在滑鼠游標懸停時,在文字底部顯示底線。

UnderlineMode UNDERLINE_MODE_NEVER = 2

LinkButton 永遠不會在其文字底部顯示底線。


屬性說明

String ellipsis_char = "…" 🔗

  • void set_ellipsis_char(value: String)

  • String get_ellipsis_char()

Ellipsis character used for text clipping.


String language = "" 🔗

Language code used for line-breaking and text shaping algorithms. If left empty, the current locale is used instead.


StructuredTextParser structured_text_bidi_override = 0 🔗

為結構化文字設定 BiDi 演算法覆蓋。


Array structured_text_bidi_override_options = [] 🔗

  • void set_structured_text_bidi_override_options(value: Array)

  • Array get_structured_text_bidi_override_options()

設定 BiDi 覆蓋的附加選項。


String text = "" 🔗

該按鈕的文字,將顯示在按鈕的區域內。


TextDirection text_direction = 0 🔗

基礎文字書寫方向。


OverrunBehavior text_overrun_behavior = 0 🔗

Sets the clipping behavior when the text exceeds the node's bounding rectangle.


UnderlineMode underline = 0 🔗

The underline mode to use for the text.


String uri = "" 🔗

The URI for this LinkButton. If set to a valid URI, pressing the button opens the URI using the operating system's default program for the protocol (via OS.shell_open()). HTTP and HTTPS URLs open the default web browser.

uri = "https://godotengine.org"  # Opens the URL in the default web browser.
uri = "C:\SomeFolder"  # Opens the file explorer at the given path.
uri = "C:\SomeImage.png"  # Opens the given image in the default viewing app.

主題屬性說明

Color font_color = Color(0.875, 0.875, 0.875, 1) 🔗

LinkButton 預設的字形顏色 Color


Color font_disabled_color = Color(0, 0, 0, 1) 🔗

Button 處於禁用狀態時,使用的文字 Color


Color font_focus_color = Color(0.95, 0.95, 0.95, 1) 🔗

LinkButton 獲得焦點時使用的文字 Color。只替換按鈕的正常文字顏色。禁用、懸停和按下狀態優先於這個顏色。


Color font_hover_color = Color(0.95, 0.95, 0.95, 1) 🔗

LinkButton 被懸停時使用的文字顏色 Color


Color font_hover_pressed_color = Color(0, 0, 0, 1) 🔗

Button 處於懸停並按下狀態時,使用的文字 Color


Color font_outline_color = Color(0, 0, 0, 1) 🔗

LinkButton 的文字輪廓的色調。


Color font_pressed_color = Color(1, 1, 1, 1) 🔗

LinkButton 被按下時使用的文字顏色 Color


int outline_size = 0 🔗

文字輪廓的大小。

注意:如果使用啟用了 FontFile.multichannel_signed_distance_field 的字形,其 FontFile.msdf_pixel_range 必須至少設定為 outline_size兩倍,輪廓算繪才能看起來正確。否則,輪廓可能會比預期的更早被切斷。


int underline_spacing = 2 🔗

文字基線和底線之間的垂直空間。


Font font 🔗

LinkButton 文字的字形 Font


int font_size 🔗

LinkButton 文字的字形大小。


StyleBox focus 🔗

StyleBox used when the LinkButton is focused. The focus StyleBox is displayed over the base StyleBox, so a partially transparent StyleBox should be used to ensure the base StyleBox remains visible. A StyleBox that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a StyleBoxEmpty resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.