| 192 | } |
| 193 | |
| 194 | bool Entry::onProcessMessage(Message* msg) |
| 195 | { |
| 196 | switch (msg->type()) { |
| 197 | case kTimerMessage: |
| 198 | if (hasFocus() && static_cast<TimerMessage*>(msg)->timer() == &m_timer) { |
| 199 | // Blinking caret |
| 200 | m_state = m_state ? false: true; |
| 201 | invalidate(); |
| 202 | } |
| 203 | break; |
| 204 | |
| 205 | case kFocusEnterMessage: { |
| 206 | m_got_focus_message = true; |
| 207 | View* view = View::getView(this); |
| 208 | gfx::Rect rect = view ? view->viewportBounds() : bounds(); |
| 209 | int scale = 2*guiscale(); |
| 210 | rect.x *= scale; |
| 211 | rect.y *= scale; |
| 212 | rect.h *= scale; |
| 213 | rect.w *= scale; |
| 214 | if (!isReadOnly() && showsKeyboard()) |
| 215 | she::set_input_rect(rect); |
| 216 | |
| 217 | m_timer.start(); |
| 218 | |
| 219 | m_state = true; |
| 220 | invalidate(); |
| 221 | |
| 222 | if (m_lock_selection) { |
| 223 | m_lock_selection = false; |
| 224 | } |
| 225 | else { |
| 226 | selectAllText(); |
| 227 | m_recent_focused = true; |
| 228 | } |
| 229 | break; |
| 230 | } |
| 231 | |
| 232 | case kFocusLeaveMessage: |
| 233 | invalidate(); |
| 234 | |
| 235 | m_timer.stop(); |
| 236 | |
| 237 | if (!m_lock_selection) |
| 238 | deselectText(); |
| 239 | |
| 240 | m_recent_focused = false; |
| 241 | m_got_focus_message = false; |
| 242 | she::set_input_rect({}); |
| 243 | break; |
| 244 | |
| 245 | case kKeyDownMessage: |
| 246 | if (hasFocus() && !isReadOnly()) { |
| 247 | if (!m_got_focus_message) |
| 248 | return true; |
| 249 | |
| 250 | // Command to execute |
| 251 | EntryCmd cmd = EntryCmd::NoOp; |
nothing calls this directly
no test coverage detected