| 1303 | |
| 1304 | /// <inheritdoc /> |
| 1305 | public override bool OnMouseDown(Float2 location, MouseButton button) |
| 1306 | { |
| 1307 | if (base.OnMouseDown(location, button)) |
| 1308 | return true; |
| 1309 | |
| 1310 | if (button == MouseButton.Left && _isSelectable) |
| 1311 | { |
| 1312 | Focus(); |
| 1313 | OnSelectingBegin(); |
| 1314 | |
| 1315 | // Calculate char index under the mouse location |
| 1316 | var hitPos = CharIndexAtPoint(ref location); |
| 1317 | |
| 1318 | // Select range with shift |
| 1319 | if (_selectionStart != -1 && RootWindow.GetKey(KeyboardKeys.Shift) && SelectionLength == 0) |
| 1320 | { |
| 1321 | if (hitPos < _selectionStart) |
| 1322 | SetSelection(hitPos, _selectionStart); |
| 1323 | else |
| 1324 | SetSelection(_selectionStart, hitPos); |
| 1325 | } |
| 1326 | else if (string.IsNullOrEmpty(_text)) |
| 1327 | { |
| 1328 | SetSelection(0); |
| 1329 | } |
| 1330 | else |
| 1331 | { |
| 1332 | SetSelection(hitPos); |
| 1333 | } |
| 1334 | |
| 1335 | if (Cursor == CursorType.Default && _changeCursor) |
| 1336 | Cursor = CursorType.IBeam; |
| 1337 | |
| 1338 | return true; |
| 1339 | } |
| 1340 | |
| 1341 | if (button == MouseButton.Left && !IsFocused) |
| 1342 | { |
| 1343 | Focus(); |
| 1344 | if (_changeCursor) |
| 1345 | Cursor = CursorType.IBeam; |
| 1346 | return true; |
| 1347 | } |
| 1348 | |
| 1349 | return false; |
| 1350 | } |
| 1351 | |
| 1352 | /// <inheritdoc /> |
| 1353 | public override bool OnMouseUp(Float2 location, MouseButton button) |