Skip to content

Commit 1b98178

Browse files
committed
Changed focus_in event to focus and focus_out to blur.
1 parent 2005fd9 commit 1b98178

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

lib/scenic/component/input/text_field.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ defmodule Scenic.Component.Input.TextField do
2222
2323
It also sends other two events when focus is gained or lost, respectively:
2424
25-
`{:focus_in, id}`
26-
`{:focus_out, id}`
25+
`{:focus, id}`
26+
`{:blur, id}`
2727
2828
## Styles
2929
@@ -262,7 +262,7 @@ defmodule Scenic.Component.Input.TextField do
262262
defp capture_focus(%{assigns: %{focused: false, graph: graph, id: id, theme: theme}} = scene) do
263263
# capture the input
264264
capture_input(scene, @input_capture)
265-
:ok = send_parent_event(scene, {:focus_in, id})
265+
:ok = send_parent_event(scene, {:focus, id})
266266

267267
# start animating the caret
268268
cast_children(scene, :start_caret)
@@ -283,7 +283,7 @@ defmodule Scenic.Component.Input.TextField do
283283
defp release_focus(%{assigns: %{focused: true, graph: graph, id: id, theme: theme}} = scene) do
284284
# release the input
285285
release_input(scene)
286-
:ok = send_parent_event(scene, {:focus_out, id})
286+
:ok = send_parent_event(scene, {:blur, id})
287287

288288
# stop animating the caret
289289
cast_children(scene, :stop_caret)

test/scenic/component/input/text_field_test.exs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,29 +94,29 @@ defmodule Scenic.Component.Input.TextFieldTest do
9494
:_pong_ = GenServer.call(vp_pid, :_ping_)
9595
end
9696

97-
test "press_in captures, starts editing and fire focus_in event", %{vp: vp, pid: pid} do
97+
test "press_in captures, starts editing and fire focus event", %{vp: vp, pid: pid} do
9898
assert Input.fetch_captures!(vp) == {:ok, []}
9999
Input.send(vp, @press_in)
100100
force_sync(vp.pid, pid)
101101

102102
assert Input.fetch_captures!(vp) ~> {:ok, sorted_list([:codepoint, :cursor_button, :key])}
103-
assert_receive({:fwd_event, {:focus_in, :text_field}}, 200)
103+
assert_receive({:fwd_event, {:focus, :text_field}}, 200)
104104

105105
Input.send(vp, @cp_k)
106106
assert_receive({:fwd_event, {:value_changed, :text_field, "kInitial value"}}, 200)
107107
end
108108

109-
test "press_out releases, ends editing and fire focus_out event", %{vp: vp, pid: pid} do
109+
test "press_out releases, ends editing and fire blur event", %{vp: vp, pid: pid} do
110110
Input.send(vp, @press_in)
111111
force_sync(vp.pid, pid)
112112

113113
assert Input.fetch_captures!(vp) ~> {:ok, sorted_list([:codepoint, :cursor_button, :key])}
114-
assert_receive({:fwd_event, {:focus_in, :text_field}}, 200)
114+
assert_receive({:fwd_event, {:focus, :text_field}}, 200)
115115

116116
Input.send(vp, @press_out)
117117
force_sync(vp.pid, pid)
118118
assert Input.fetch_captures!(vp) == {:ok, []}
119-
assert_receive({:fwd_event, {:focus_out, :text_field}}, 200)
119+
assert_receive({:fwd_event, {:blur, :text_field}}, 200)
120120

121121
Input.send(vp, @cp_k)
122122
refute_receive(_, 10)
@@ -125,7 +125,7 @@ defmodule Scenic.Component.Input.TextFieldTest do
125125
test "pressing in the field moves the cursor to the nearst character gap", %{vp: vp, pid: pid} do
126126
Input.send(vp, @press_in)
127127
force_sync(vp.pid, pid)
128-
assert_receive({:fwd_event, {:focus_in, :text_field}}, 200)
128+
assert_receive({:fwd_event, {:focus, :text_field}}, 200)
129129

130130
Input.send(vp, @cp_k)
131131
assert_receive({:fwd_event, {:value_changed, :text_field, "kInitial value"}}, 200)
@@ -206,7 +206,7 @@ defmodule Scenic.Component.Input.TextFieldTest do
206206
test "backspace does nothing at the start of the string", %{vp: vp, pid: pid} do
207207
Input.send(vp, @press_in)
208208
force_sync(vp.pid, pid)
209-
assert_receive({:fwd_event, {:focus_in, :text_field}}, 200)
209+
assert_receive({:fwd_event, {:focus, :text_field}}, 200)
210210

211211
Input.send(vp, @key_backspace)
212212
refute_receive(_, 10)
@@ -223,7 +223,7 @@ defmodule Scenic.Component.Input.TextFieldTest do
223223
test "delete does nothing at the end of the field", %{vp: vp, pid: pid} do
224224
Input.send(vp, @press_in)
225225
force_sync(vp.pid, pid)
226-
assert_receive({:fwd_event, {:focus_in, :text_field}}, 200)
226+
assert_receive({:fwd_event, {:focus, :text_field}}, 200)
227227

228228
Input.send(vp, @key_end)
229229
Input.send(vp, @key_delete)
@@ -236,7 +236,7 @@ defmodule Scenic.Component.Input.TextFieldTest do
236236

237237
Input.send(vp, {:cursor_button, {:btn_left, 1, [], {20, 60}}})
238238
force_sync(vp.pid, pid)
239-
assert_receive({:fwd_event, {:focus_in, :number_field}}, 200)
239+
assert_receive({:fwd_event, {:focus, :number_field}}, 200)
240240

241241
Input.send(vp, {:codepoint, {"a", []}})
242242
refute_receive(_, 10)
@@ -256,7 +256,7 @@ defmodule Scenic.Component.Input.TextFieldTest do
256256

257257
Input.send(vp, {:cursor_button, {:btn_left, 1, [], {14, 86}}})
258258
force_sync(vp.pid, pid)
259-
assert_receive({:fwd_event, {:focus_in, :integer_field}}, 200)
259+
assert_receive({:fwd_event, {:focus, :integer_field}}, 200)
260260

261261
Input.send(vp, {:codepoint, {"a", []}})
262262
refute_receive(_, 10)
@@ -276,7 +276,7 @@ defmodule Scenic.Component.Input.TextFieldTest do
276276

277277
Input.send(vp, {:cursor_button, {:btn_left, 1, [], {14, 121}}})
278278
force_sync(vp.pid, pid)
279-
assert_receive({:fwd_event, {:focus_in, :abcdefg_field}}, 200)
279+
assert_receive({:fwd_event, {:focus, :abcdefg_field}}, 200)
280280

281281
Input.send(vp, {:codepoint, {"a", []}})
282282
assert_receive({:fwd_event, {:value_changed, :abcdefg_field, "a"}}, 200)
@@ -294,7 +294,7 @@ defmodule Scenic.Component.Input.TextFieldTest do
294294

295295
Input.send(vp, {:cursor_button, {:btn_left, 1, [], {14, 171}}})
296296
force_sync(vp.pid, pid)
297-
assert_receive({:fwd_event, {:focus_in, :fn_field}}, 200)
297+
assert_receive({:fwd_event, {:focus, :fn_field}}, 200)
298298

299299
Input.send(vp, {:codepoint, {"a", []}})
300300
refute_receive(_, 10)

0 commit comments

Comments
 (0)