| 307 | } |
| 308 | |
| 309 | bool TextEdit::OnMouseUp(const Point& pos, int key) |
| 310 | { |
| 311 | if (mouse_selecting && key == IK_LeftMouse) |
| 312 | { |
| 313 | if (ignore_mouse_events) // This prevents text selection from changing from what was set when focus was gained. |
| 314 | { |
| 315 | ReleaseMouseCapture(); |
| 316 | ignore_mouse_events = false; |
| 317 | mouse_selecting = false; |
| 318 | } |
| 319 | else |
| 320 | { |
| 321 | scroll_timer->Stop(); |
| 322 | ReleaseMouseCapture(); |
| 323 | mouse_selecting = false; |
| 324 | ivec2 sel_end = GetCharacterIndex(pos); |
| 325 | selection_length = ToOffset(sel_end) - ToOffset(selection_start); |
| 326 | cursor_pos = sel_end; |
| 327 | SetFocus(); |
| 328 | Update(); |
| 329 | } |
| 330 | } |
| 331 | return true; |
| 332 | } |
| 333 | |
| 334 | void TextEdit::OnKeyChar(std::string chars) |
| 335 | { |