Skip to content

Commit 2005fd9

Browse files
committed
Added documentation for new events.
1 parent 5833118 commit 2005fd9

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

lib/scenic/component/button.ex

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@ defmodule Scenic.Component.Button do
2222
If a button press is successful, it sends an event message to the host scene
2323
in the form of:
2424
25-
{:click, id}
25+
`{:click, id}`
26+
27+
This event is only sent after the button is released. There're also, though,
28+
two other events that you can receive:
29+
30+
`{:btn_pressed, id}`
31+
32+
and
33+
34+
`{:btn_released, id}`
2635
2736
These messages can be received and handled in your scene via
2837
`c:Scenic.Scene.handle_event/3`. For example:

lib/scenic/component/input/dropdown.ex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ defmodule Scenic.Component.Input.Dropdown do
3131
3232
`{:value_changed, id, selected_item_id}`
3333
34+
It also send the following events:
35+
36+
`{:dropdown_opened, id}` - sent when the dropdown opens
37+
`{:dropdown_closed, id}` - sent when the dropdown closes
38+
`{:dropdown_item_hover, id, item_id}` - sent when and item is hovered
39+
3440
## Options
3541
3642
Dropdowns honor the following list of options.
@@ -431,6 +437,7 @@ defmodule Scenic.Component.Input.Dropdown do
431437
%Scene{
432438
assigns: %{
433439
down: true,
440+
id: component_id,
434441
items: items,
435442
graph: graph,
436443
selected_id: selected_id,
@@ -441,7 +448,7 @@ defmodule Scenic.Component.Input.Dropdown do
441448
# set the appropriate hilighting for each of the items
442449
graph = update_highlighting(graph, items, selected_id, id, theme)
443450

444-
:ok = send_parent_event(scene, {:dropdown_item_hover, id})
451+
:ok = send_parent_event(scene, {:dropdown_item_hover, component_id, id})
445452

446453
scene =
447454
scene

lib/scenic/component/input/text_field.ex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ defmodule Scenic.Component.Input.TextField do
2020
2121
`{:value_changed, id, value}`
2222
23+
It also sends other two events when focus is gained or lost, respectively:
24+
25+
`{:focus_in, id}`
26+
`{:focus_out, id}`
27+
2328
## Styles
2429
2530
Text fields honor the following styles

test/scenic/component/input/dropdown_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ defmodule Scenic.Component.Input.DropdownTest do
170170

171171
Input.send(vp, @hover_a)
172172
force_sync(vp.pid, comp_pid)
173-
assert_receive({:fwd_event, {:dropdown_item_hover, 1}}, 100)
173+
assert_receive({:fwd_event, {:dropdown_item_hover, :dropdown, 1}}, 100)
174174

175175
Input.send(vp, @hover_b)
176176
force_sync(vp.pid, comp_pid)
177-
assert_receive({:fwd_event, {:dropdown_item_hover, 2}}, 100)
177+
assert_receive({:fwd_event, {:dropdown_item_hover, :dropdown, 2}}, 100)
178178

179179
refute_receive(_, 10)
180180
end

0 commit comments

Comments
 (0)