@@ -18,9 +18,9 @@ defmodule Scenic.Component.Input.Caret do
18
18
@ width 2
19
19
@ inset_v 4
20
20
21
- # carat blink speed in hertz
22
- @ carat_hz 1.5
23
- @ carat_ms trunc ( @ carat_hz * 500 )
21
+ # caret blink speed in hertz
22
+ @ caret_hz 1.5
23
+ @ caret_ms trunc ( @ caret_hz * 500 )
24
24
25
25
# ============================================================================
26
26
# setup
@@ -70,22 +70,22 @@ defmodule Scenic.Component.Input.Caret do
70
70
end
71
71
72
72
# --------------------------------------------------------
73
- def handle_cast ( :gain_focus , % { graph: graph , timer: nil } = state ) do
74
- # turn on the carat
73
+ def handle_cast ( :start_caret , % { graph: graph , timer: nil } = state ) do
74
+ # turn on the caret
75
75
graph =
76
76
graph
77
77
|> Graph . modify ( :caret , & update_opts ( & 1 , hidden: false ) )
78
78
|> push_graph ( )
79
79
80
80
# start the timer
81
- { :ok , timer } = :timer . send_interval ( @ carat_ms , :blink )
81
+ { :ok , timer } = :timer . send_interval ( @ caret_ms , :blink )
82
82
83
83
{ :noreply , % { state | graph: graph , hidden: false , timer: timer , focused: true } }
84
84
end
85
85
86
86
# --------------------------------------------------------
87
- def handle_cast ( :lose_focus , % { graph: graph , timer: timer } = state ) do
88
- # hide the carat
87
+ def handle_cast ( :stop_caret , % { graph: graph , timer: timer } = state ) do
88
+ # hide the caret
89
89
graph =
90
90
graph
91
91
|> Graph . modify ( :caret , & update_opts ( & 1 , hidden: true ) )
@@ -102,10 +102,10 @@ defmodule Scenic.Component.Input.Caret do
102
102
103
103
# --------------------------------------------------------
104
104
def handle_cast (
105
- :reset_carat ,
105
+ :reset_caret ,
106
106
% { graph: graph , timer: timer , focused: true } = state
107
107
) do
108
- # show the carat
108
+ # show the caret
109
109
graph =
110
110
graph
111
111
|> Graph . modify ( :caret , & update_opts ( & 1 , hidden: false ) )
@@ -115,7 +115,7 @@ defmodule Scenic.Component.Input.Caret do
115
115
if timer , do: :timer . cancel ( timer )
116
116
117
117
# restart the timer
118
- { :ok , timer } = :timer . send_interval ( @ carat_ms , :blink )
118
+ { :ok , timer } = :timer . send_interval ( @ caret_ms , :blink )
119
119
120
120
{ :noreply , % { state | graph: graph , hidden: false , timer: timer } }
121
121
end
0 commit comments