Class LinkButton

All Implemented Interfaces:
PointerInterface

public class LinkButton extends Button
A `GtkLinkButton` is a button with a hyperlink.

![An example GtkLinkButton](link-button.png)

It is useful to show quick links to resources.

A link button is created by calling either [ctor@Gtk.LinkButton.new] or
[ctor@Gtk.LinkButton.new_with_label]. If using the former, the URI you
pass to the constructor is used as a label for the widget.

The URI bound to a `GtkLinkButton` can be set specifically using
[method@Gtk.LinkButton.set_uri].

By default, `GtkLinkButton` calls [func@Gtk.show_uri] when the button
is clicked. This behaviour can be overridden by connecting to the
[signal@Gtk.LinkButton::activate-link] signal and returning %TRUE from
the signal handler.

# CSS nodes

`GtkLinkButton` has a single CSS node with name button. To differentiate
it from a plain `GtkButton`, it gets the .link style class.

# Accessibility

`GtkLinkButton` uses the %GTK_ACCESSIBLE_ROLE_LINK role.

https://docs.gtk.org/gtk4/class.LinkButton.html

  • Field Details

  • Constructor Details

    • LinkButton

      public LinkButton(PointerContainer pointer)
    • LinkButton

      public LinkButton(@Nonnull Str uri)
      Creates a new `GtkLinkButton` with the URI as its text.
      Parameters:
      uri - a valid URI
    • LinkButton

      public LinkButton(String uri)
      Creates a new `GtkLinkButton` with the URI as its text.
      Parameters:
      uri - a valid URI
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • newWithLabelLinkButton

      public static LinkButton newWithLabelLinkButton(@Nonnull Str uri, @Nullable Str label)
      Creates a new `GtkLinkButton` containing a label.
      Parameters:
      uri - a valid URI
      label - the text of the button
      Returns:
      a new link button widget.
    • newWithLabelLinkButton

      public static LinkButton newWithLabelLinkButton(String uri, String label)
      Creates a new `GtkLinkButton` containing a label.
      Parameters:
      uri - a valid URI
      label - the text of the button
      Returns:
      a new link button widget.
    • getUri

      public Str getUri()
      Retrieves the URI of the `GtkLinkButton`.
      Returns:
      a valid URI. The returned string is owned by the link button and should not be modified or freed.
    • getVisited

      public boolean getVisited()
      Retrieves the “visited” state of the `GtkLinkButton`.

      The button becomes visited when it is clicked. If the URI
      is changed on the button, the “visited” state is unset again.

      The state may also be changed using [method@Gtk.LinkButton.set_visited].
      Returns:
      %TRUE if the link has been visited, %FALSE otherwise
    • setUri

      public void setUri(@Nonnull Str uri)
      Sets @uri as the URI where the `GtkLinkButton` points.

      As a side-effect this unsets the “visited” state of the button.
      Parameters:
      uri - a valid URI
    • setUri

      public void setUri(String uri)
      Sets @uri as the URI where the `GtkLinkButton` points.

      As a side-effect this unsets the “visited” state of the button.
      Parameters:
      uri - a valid URI
    • setVisited

      public void setVisited(boolean visited)
      Sets the “visited” state of the `GtkLinkButton`.

      See [method@Gtk.LinkButton.get_visited] for more details.
      Parameters:
      visited - the new “visited” state
    • onActivateLink

      public SignalHandler onActivateLink(LinkButton.OnActivateLink signal)
      Connect to signal "activate-link".
      See LinkButton.OnActivateLink.onActivateLink() for signal description.
      Field SIGNAL_ON_ACTIVATE_LINK contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • asAccessible

      public Accessible asAccessible()
      Implements interface Accessible. Call this to get access to interface functions.
      Overrides:
      asAccessible in class Button
      Returns:
      Accessible
    • asActionable

      public Actionable asActionable()
      Implements interface Actionable. Call this to get access to interface functions.
      Overrides:
      asActionable in class Button
      Returns:
      Actionable
    • asBuildable

      public Buildable asBuildable()
      Implements interface Buildable. Call this to get access to interface functions.
      Overrides:
      asBuildable in class Button
      Returns:
      Buildable
    • asConstraintTarget

      public ConstraintTarget asConstraintTarget()
      Implements interface ConstraintTarget. Call this to get access to interface functions.
      Overrides:
      asConstraintTarget in class Button
      Returns:
      ConstraintTarget
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()