Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
Add support for tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
david-swift committed Feb 26, 2024
1 parent cf0b4b4 commit 24fc372
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Sources/Adwaita/View/Modifiers/InspectorWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,11 @@ extension View {
}
}

/// Add a tooltip to the widget.
/// - Parameter tooltip: The tooltip text.
/// - Returns: A view.
public func tooltip(_ tooltip: String) -> View {
inspect { gtk_widget_set_tooltip_markup($0.pointer?.cast(), tooltip) }
}

}
2 changes: 2 additions & 0 deletions Tests/Demo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ struct Demo: App {
.topToolbar {
HeaderBar {
Toggle(icon: .default(icon: .sidebarShow), isOn: $sidebarVisible)
.tooltip("Toggle Sidebar")
} end: {
if sidebarVisible {
Text("")
Expand Down Expand Up @@ -148,6 +149,7 @@ struct Demo: App {
}
}
.primary()
.tooltip("Main Menu")
}

}
Expand Down

0 comments on commit 24fc372

Please sign in to comment.