Button
A button you can click.
Config is a struct of the following type:
struct {
/// The label the button will take. For example, if this is 'Test',
/// the user will see a button which, at the center, has the text 'Test'
label: [:0]const u8 = "",
enabled: bool = true,
/// The callback that will be called when the button is pressed
onclick: ?fn(button: *Button_Impl) = null
};
Functions
None specific to this component.
Properties
Name | Type | Description |
---|---|---|
label | []const u8 | The text label which appears inside the button |
enabled | bool | Whether the button can be pressed or not, defaults to true . |
Examples
Making a button labeled 'Click Me' that changes to 'Stop!' once its clicked:
- Zig
- C
fn onButtonClicked(button: *capy.Button_Impl) !void {
button.setLabel("Stop!");
}
try window.set(
capy.Button(.{ .label = "Click Me", .onclick = onButtonClicked })
);
CapyWidget button = capy_button("Hello");