forked from aparoksha/adwaita-swift
Add view modifier to set focus only
This commit is contained in:
parent
9e05b2692b
commit
b13fbcbcf1
@ -165,6 +165,12 @@ Bind to the view's focus.
|
|||||||
- Parameter focus: Whether the view is focused.
|
- Parameter focus: Whether the view is focused.
|
||||||
- Returns: A view.
|
- Returns: A view.
|
||||||
|
|
||||||
|
### `focus(_:)`
|
||||||
|
|
||||||
|
Bind a signal that focuses the view.
|
||||||
|
- Parameter focus: Whether the view is focused.
|
||||||
|
- Returns: A view.
|
||||||
|
|
||||||
### `stopModifiers()`
|
### `stopModifiers()`
|
||||||
|
|
||||||
Remove all of the content modifiers for the wrapped views.
|
Remove all of the content modifiers for the wrapped views.
|
||||||
|
|||||||
@ -155,4 +155,15 @@ extension View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Bind a signal that focuses the view.
|
||||||
|
/// - Parameter focus: Whether the view is focused.
|
||||||
|
/// - Returns: A view.
|
||||||
|
public func focus(_ signal: Signal) -> View {
|
||||||
|
inspect { storage in
|
||||||
|
if signal.update {
|
||||||
|
gtk_widget_grab_focus(storage.pointer?.cast())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,6 +48,7 @@ There are many more widgets available using auto-generation. Learn [how to use t
|
|||||||
| `insensitive(_:)` | Make a view unable to detect actions. This is especially useful for overlays. |
|
| `insensitive(_:)` | Make a view unable to detect actions. This is especially useful for overlays. |
|
||||||
| `onClick(handler:)` | Run a function when the user clicks on the widget. |
|
| `onClick(handler:)` | Run a function when the user clicks on the widget. |
|
||||||
| `focused(_:)` | Set and observe whether a view is focused. |
|
| `focused(_:)` | Set and observe whether a view is focused. |
|
||||||
|
| `focus(_:)` | Bind a signal that focuses the view. |
|
||||||
| `verticalCenter()` | Wrap a view in a `VStack` and center vertically. |
|
| `verticalCenter()` | Wrap a view in a `VStack` and center vertically. |
|
||||||
| `horizontalCenter()` | Wrap a view in an `HStack` and center horizontally. |
|
| `horizontalCenter()` | Wrap a view in an `HStack` and center horizontally. |
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user