Fixed: timing of CPControlTextDidBeginEditingNotification (#1941)

This commit is contained in:
daboe01 committed 2026-03-07 14:53:44 +01:00
1 parent da35d6b6ed
commit d0d7033f63
2 files changed
+8 -2

No files matched your search

+6
View File
@@ -1131,6 +1131,12 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
if (![self isEnabled] || !([self isEditable] || [self isSelectable]))
return;
if ([self isEditable] && !_isEditing)
{
_isEditing = YES;
[self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]];
}
// CPTextField uses an HTML input element to take the input so we need to
// propagate the dom event so the element is updated. This has to be done
// before interpretKeyEvents: though so individual commands have a chance
+2 -2
View File
@@ -453,8 +453,8 @@ CPTokenFieldDeleteButtonType = 1;
{
[_tokenScrollView documentView]._DOMElement.appendChild(element);
//post CPControlTextDidBeginEditingNotification
[self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]];
// Removed so CPTokenField doesn't fire the notification the moment it becomes the first responder, but instead defers to the first keystroke, just like Cocoa (see keyDown: in CPTextField).
// [self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]];
[[CPRunLoop mainRunLoop] performBlock:function()
{