diff --git a/Sources/Adwaita/View/Modifiers/InspectorWrapper.swift b/Sources/Adwaita/View/Modifiers/InspectorWrapper.swift index ad28180..123e3a0 100644 --- a/Sources/Adwaita/View/Modifiers/InspectorWrapper.swift +++ b/Sources/Adwaita/View/Modifiers/InspectorWrapper.swift @@ -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) } + } + } diff --git a/Tests/Demo.swift b/Tests/Demo.swift index 03ad844..6b55dd4 100644 --- a/Tests/Demo.swift +++ b/Tests/Demo.swift @@ -108,6 +108,7 @@ struct Demo: App { .topToolbar { HeaderBar { Toggle(icon: .default(icon: .sidebarShow), isOn: $sidebarVisible) + .tooltip("Toggle Sidebar") } end: { if sidebarVisible { Text("") @@ -148,6 +149,7 @@ struct Demo: App { } } .primary() + .tooltip("Main Menu") } }