fixed: redraw issues

This commit is contained in:
daboe01
2026-06-03 19:19:36 +02:00
parent 5e0fc1cbb5
commit 750c123d1e
3 changed files with 50 additions and 3 deletions
+20
View File
@@ -207,8 +207,28 @@ var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
[self registerForDraggedTypes:[CPArray arrayWithObjects:CPRuleEditorItemPBoardType,nil]];
[_boundArrayOwner addObserver:self forKeyPath:_boundArrayKeyPath options:CPKeyValueObservingOptionOld | CPKeyValueObservingOptionNew context:boundArrayContext];
[[CPNotificationCenter defaultCenter] addObserver:self
selector:@selector(_ruleEditorLocalizerDidLoad:)
name:@"_CPRuleEditorLocalizerDidLoadNotification"
object:nil];
}
- (void)_ruleEditorLocalizerDidLoad:(CPNotification)aNotification
{
if ([aNotification object] === [self standardLocalizer])
{
// Defer execution to the next run loop cycle so that any active slice
// insertions have fully completed and are present in the `_slices` array.
[[CPRunLoop mainRunLoop] performBlock:function() {
var count = [_slices count];
for (var i = 0; i < count; i++)
{
[[_slices objectAtIndex:i] _reconfigureSubviews];
}
} argument:nil order:0 modes:[CPDefaultRunLoopMode]];
}
}
/*! @endcond */
/*!
@@ -77,6 +77,9 @@ var LocalizerStringsRegex = new RegExp("\"(.+)\"\\s*=\\s*\"(.+)\"\\s*;\\s*(//.+)
}
_dictionary = [CPDictionary dictionaryWithDictionary:dict];
// Post notification to let the rule editor know the translation dictionary is ready
[[CPNotificationCenter defaultCenter] postNotificationName:@"_CPRuleEditorLocalizerDidLoadNotification" object:self];
}
- (CPString)localizedStringForString:(CPString)aString
@@ -17,7 +17,8 @@
if ([criterion isEqualToString:@"firstName"] || [criterion isEqualToString:@"lastName"])
{
return [@[@"contains", @"is equal to"] objectAtIndex:index];
// "is equal to" is placed at index 0 so that the reordered Spanish sentence layout loads automatically on startup
return [@[@"is equal to", @"contains"] objectAtIndex:index];
}
if ([criterion isEqualToString:@"age"])
@@ -54,7 +55,7 @@
if ([criterion isEqualToString:@"contains"] || [criterion isEqualToString:@"is equal to"])
{
// Operators have one child representing the input field value
// Operators have 1 child representing the value node
return 1;
}
@@ -104,7 +105,30 @@
}
else if ([criterion isEqualToString:@"value"])
{
[parts setObject:[CPExpression expressionForConstantValue:[value stringValue]] forKey:CPRuleEditorPredicateRightExpression];
// Resolve the correct active text field from the slice row on screen
var activeValue = value;
var slices = [editor valueForKey:@"_slices"];
if (slices && row < [slices count])
{
var slice = [slices objectAtIndex:row];
var optionViews = [slice valueForKey:@"_ruleOptionViews"];
if (optionViews)
{
var count = [optionViews count];
for (var i = 0; i < count; i++)
{
var view = [optionViews objectAtIndex:i];
if ([view isKindOfClass:[CPTextField class]] && [view isEditable])
{
activeValue = view;
break;
}
}
}
}
[parts setObject:[CPExpression expressionForConstantValue:[activeValue stringValue]] forKey:CPRuleEditorPredicateRightExpression];
}
return parts;