|
1 | 1 | using System;
|
2 | 2 | using Tizen.UIExtensions.ElmSharp;
|
| 3 | +using SmartEvent = ElmSharp.SmartEvent; |
3 | 4 | using EEntry = ElmSharp.Entry;
|
4 | 5 |
|
5 | 6 | namespace Microsoft.Maui.Handlers
|
@@ -155,6 +156,21 @@ public static void MapKeyboard(EditorHandler handler, IEntry entry)
|
155 | 156 | handler.PlatformView?.UpdateKeyboard(entry);
|
156 | 157 | }
|
157 | 158 |
|
| 159 | + public static void MapSelectionLength(EntryHandler handler, IEntry entry) |
| 160 | + { |
| 161 | + handler.NativeView?.UpdateSelectionLength(entry); |
| 162 | + } |
| 163 | + |
| 164 | + public static void MapCursorPosition(EntryHandler handler, IEntry entry) |
| 165 | + { |
| 166 | + handler.NativeView?.UpdateSelectionLength(entry); |
| 167 | + } |
| 168 | + |
| 169 | + public static void MapKeyboard(EditorHandler handler, IEditor editor) |
| 170 | + { |
| 171 | + handler.NativeView?.UpdateKeyboard(editor); |
| 172 | + } |
| 173 | + |
158 | 174 | [MissingMapper]
|
159 | 175 | public static void MapCharacterSpacing(IEntryHandler handler, IEntry entry) { }
|
160 | 176 |
|
@@ -208,6 +224,37 @@ void OnSelectionCleared(object? sender, EventArgs e)
|
208 | 224 | }
|
209 | 225 | }
|
210 | 226 |
|
| 227 | + void OnCursorChanged(object? sender, EventArgs e) |
| 228 | + { |
| 229 | + if (VirtualView == null || NativeView == null) |
| 230 | + return; |
| 231 | + |
| 232 | + var position = NativeView.CursorPosition; |
| 233 | + |
| 234 | + NativeView.GetSelectRegion(out int start, out int end); |
| 235 | + |
| 236 | + if (start > -1) |
| 237 | + { |
| 238 | + position = (start < end) ? start : end; |
| 239 | + var selectionLength = Math.Abs(end - start); |
| 240 | + VirtualView.SelectionLength = selectionLength; |
| 241 | + } |
| 242 | + |
| 243 | + VirtualView.CursorPosition = position; |
| 244 | + } |
| 245 | + |
| 246 | + void OnSelectionCleared(object sender, EventArgs e) |
| 247 | + { |
| 248 | + if (VirtualView == null || NativeView == null) |
| 249 | + return; |
| 250 | + |
| 251 | + if (NativeView.IsFocused) |
| 252 | + { |
| 253 | + VirtualView.SelectionLength = 0; |
| 254 | + VirtualView.CursorPosition = NativeView.CursorPosition; |
| 255 | + } |
| 256 | + } |
| 257 | + |
211 | 258 | void OnCompleted(object? sender, EventArgs e)
|
212 | 259 | {
|
213 | 260 | if (PlatformView == null)
|
|
0 commit comments