Skip to content

Commit 6877525

Browse files
committed
add docs for GtkSpinButton and GtkScale
1 parent ed55f9d commit 6877525

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed

docs/make.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ makedocs(
2828
"manual/menus.md",
2929
"manual/dialogs.md",
3030
"manual/textwidgets.md",
31+
"manual/input.md",
3132
"manual/display.md",
3233
"manual/combobox.md",
3334
"manual/listtreeview.md",

docs/src/manual/combobox.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ push!(m, "five")
4242
More complex uses of `GtkDropDown` are possible by using models other than
4343
`GtkStringList`. This may be supported in future versions of Gtk4.jl.
4444

45+
| signal | arguments | returns | |
46+
| :--- | :--- | :--- | :--- |
47+
| "notify::selected" | self::GtkDropDown, paramspec::GParamSpec | `Nothing` | Emitted when selection is changed |
48+
49+
4550
## [GtkComboBox](https://docs.gtk.org/gtk4/class.ComboBox.html)
4651

4752
The older API for dropdown menu functionality is `GtkComboBox`.

docs/src/manual/input.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Numeric input widgets
2+
3+
Gtk4 provides a few different widgets for user input of numeric values.
4+
5+
## [GtkScale](https://docs.gtk.org/gtk4/class.Scale.html)
6+
7+
The `GtkScale` widget allows users to select a value by sliding a knob within a predefined range. It is a subclass of [`GtkRange`](https://docs.gtk.org/gtk4/class.Range.html) and displays a slider and, optionally, text showing the current value.
8+
9+
A `GtkScale` is typically created using one of the following constructors:
10+
11+
* `GtkScale(orientation, range::AbstractRange)` creates a new `GtkScale` with the specified orientation (`:h`/`Orientation_HORIZONTAL` or `:v`/`Orientation_VERTICAL`), with the range of allowed values defined by `range`.
12+
* `GtkScale(orientation, min_val, max_val, step)` creates a new `GtkScale` with the range of allowed values defined by `min_val`, `max_val`, and `step`.
13+
* `GtkScale(orientation, adj::GtkAdjustment)` creates a new `GtkScale` using an existing [`GtkAdjustment`](https://docs.gtk.org/gtk4/class.Adjustment.html) object to manage the range and value.
14+
15+
### Example
16+
17+
```julia
18+
using Gtk4
19+
20+
# Create a horizontal scale for integers from 0 to 100
21+
scale = GtkScale(:h, 0.0, 100.0, 1.0)
22+
23+
# Set the initial value
24+
Gtk4.value(scale, 50.0)
25+
```
26+
27+
### Useful properties and signals
28+
29+
| property | type | |
30+
| :--- | :--- | :--- |
31+
| `value` | `Float64` | The current value of the slider. Get/set using `Gtk4.value(widget)` and `Gtk4.value(widget, val)`. |
32+
| `draw_value` | `Bool` | Whether the current value is displayed next to the slider. Defaults to `false`. |
33+
| `digits` | `Int` | The number of decimal places to display for the value. |
34+
| `adjustment` | `GtkAdjustment` | The `GtkAdjustment` managing the scale's range, value, and step. |
35+
36+
The most important signal for interacting with the scale's value is inherited from `GtkRange`:
37+
38+
| signal | arguments | returns | |
39+
| :--- | :--- | :--- | :--- |
40+
| "value-changed" | self::GtkScale | `Nothing` | Emitted when the value is changed |
41+
42+
## [GtkSpinButton](https://docs.gtk.org/gtk4/class.SpinButton.html)
43+
44+
The `GtkSpinButton` widget allows a user to select a value from a numerical range by typing in a text field or by clicking a pair of up/down buttons.
45+
A `GtkSpinButton` is typically created using one of the following constructors:
46+
47+
* `GtkSpinButton(min_val, max_val, step_increment)` creates a new `GtkSpinButton` with the specified minimum value `min_val`, maximum value `max_val`, and increment size `step_increment`.
48+
49+
* `GtkSpinButton(adj::GtkAdjustment, climb_rate::Real, digits::Integer)` creates a new `GtkSpinButton` using an existing `GtkAdjustment` object to manage the range and value. The argument `climb_rate` is an internal scaling factor applied to the step increment when the arrow buttons are held down, while `digits` is the number of decimal places to display.
50+
51+
### Example
52+
53+
```julia
54+
using Gtk4
55+
56+
# Create a spin button for integer values from 1 to 10 with step 1
57+
spin = GtkSpinButton(1.0, 10.0, 1.0)
58+
59+
# Set the initial value
60+
Gtk4.value(spin, 5.0)
61+
```
62+
63+
### Useful properties and signals
64+
65+
| property | type | |
66+
| :--- | :--- | :--- |
67+
| `value` | `Float64` | The current numerical value of the widget. Get/set using `Gtk4.value(widget)` and `Gtk4.value(widget, val)`. |
68+
| `adjustment` | `GtkAdjustment` | The object managing the range, value, and step increment. |
69+
| `digits` | `Int` | The number of decimal places to display. |
70+
| `numeric` | `Bool` | Whether only numeric characters are allowed in the entry field. Defaults to `false`. |
71+
72+
The most common signal for tracking changes is:
73+
74+
| signal | arguments | returns | |
75+
| :--- | :--- | :--- | :--- |
76+
| "value-changed" | self::GtkSpinButton | `Nothing` | Emitted when the value is changed. |

docs/src/manual/textwidgets.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,21 @@ ent.visibility = false
6767
```
6868
To get notified by changes to the entry one can listen to the "changed" event.
6969

70+
Selected signals:
71+
72+
| signal | arguments | returns | |
73+
| :--- | :--- | :--- | :--- |
74+
| "activate" | self::GtkEntry | `Nothing` | Emitted when enter is pressed |
75+
76+
7077
The `GtkEntry` widget includes a progress bar. Methods `fraction`, `pulse`, and `pulse_step` control its appearance and work the same as for [GtkProgressBar](@ref).
7178

7279
## [GtkSearchEntry](https://docs.gtk.org/gtk4/class.SearchEntry.html)
7380

7481
A special variant of the entry that can be used as a search box is `GtkSearchEntry`. It is equipped
7582
with a button to clear the entry.
83+
84+
| signal | arguments | returns | |
85+
| :--- | :--- | :--- | :--- |
86+
| "activate" | self::GtkSearchEntry | `Nothing` | Emitted when enter is pressed |
87+

0 commit comments

Comments
 (0)