Button

using GLMakie
fig = Figure()

ax = Axis(fig[1, 1])
fig[2, 1] = buttongrid = GridLayout(tellwidth = false)

counts = Observable([1, 4, 3, 7, 2])

buttonlabels = [lift(x -> "Count: $(x[i])", counts) for i in 1:5]

buttons = buttongrid[1, 1:5] = [Button(fig, label = l) for l in buttonlabels]

for i in 1:5
    on(buttons[i].clicks) do n
        counts[][i] += 1
        notify(counts)
    end
end

barplot!(counts, color = cgrad(:Spectral)[LinRange(0, 1, 5)])
ylims!(ax, 0, 20)

fig

Attributes

alignmode

Defaults to Inside()

The align mode of the button in its parent GridLayout.

buttoncolor

Defaults to RGBf(0.94, 0.94, 0.94)

The color of the button.

buttoncolor_active

Defaults to COLOR_ACCENT[]

The color of the button when the mouse clicks the button.

buttoncolor_hover

Defaults to COLOR_ACCENT_DIMMED[]

The color of the button when the mouse hovers over the button.

clicks

Defaults to 0

The number of clicks that have been registered by the button.

cornerradius

Defaults to 4

The radius of the rounded corners of the button.

cornersegments

Defaults to 10

The number of poly segments used for each rounded corner.

font

Defaults to :regular

The font family of the button label.

fontsize

Defaults to @inherit :fontsize 16.0f0

The font size of the button label.

halign

Defaults to :center

The horizontal alignment of the button in its suggested boundingbox

height

Defaults to Auto()

The height setting of the button.

label

Defaults to "Button"

The text of the button label.

labelcolor

Defaults to @inherit :textcolor :black

The color of the label.

labelcolor_active

Defaults to :white

The color of the label when the mouse clicks the button.

labelcolor_hover

Defaults to :black

The color of the label when the mouse hovers over the button.

padding

Defaults to (10.0f0, 10.0f0, 10.0f0, 10.0f0)

The extra space added to the sides of the button label's boundingbox.

strokecolor

Defaults to :transparent

The color of the button border.

strokewidth

Defaults to 2.0

The line width of the button border.

tellheight

Defaults to true

Controls if the parent layout can adjust to this element's height

tellwidth

Defaults to true

Controls if the parent layout can adjust to this element's width

valign

Defaults to :center

The vertical alignment of the button in its suggested boundingbox

width

Defaults to Auto()

The width setting of the button.