@@ -14,6 +14,7 @@ import {
14
14
getParent ,
15
15
IEezObject ,
16
16
IMessage ,
17
+ IOnSelectParams ,
17
18
MessageType ,
18
19
PropertyInfo ,
19
20
PropertyProps ,
@@ -251,8 +252,11 @@ function getReferencedFlow(object: IEezObject): Flow | undefined {
251
252
return undefined ;
252
253
}
253
254
254
- function getPropertyInfoForUserProperty ( userProperty : UserProperty ) {
255
- return userProperty . assignable
255
+ function getPropertyInfoForUserProperty (
256
+ userProperty : UserProperty ,
257
+ parent : IEezObject
258
+ ) {
259
+ const propertyInfo = userProperty . assignable
256
260
? makeAssignableExpressionProperty (
257
261
{
258
262
name : userProperty . id ,
@@ -273,12 +277,31 @@ function getPropertyInfoForUserProperty(userProperty: UserProperty) {
273
277
} ,
274
278
userProperty . type
275
279
) ;
280
+
281
+ const onSelect = propertyInfo . onSelect ! ;
282
+
283
+ propertyInfo . onSelect = async (
284
+ object : IEezObject ,
285
+ propertyInfo : PropertyInfo ,
286
+ params ?: IOnSelectParams
287
+ ) => {
288
+ ( object as any ) . _eez_parent = parent ;
289
+
290
+ await onSelect ( object , propertyInfo , params ) ;
291
+
292
+ delete ( object as any ) . _eez_parent ;
293
+ } ;
294
+
295
+ return propertyInfo ;
276
296
}
277
297
278
298
function getUserPropertiesAsPropertyInfos (
279
- userProperties : UserProperty [ ]
299
+ userProperties : UserProperty [ ] ,
300
+ parent : IEezObject
280
301
) : PropertyInfo [ ] {
281
- return userProperties . map ( getPropertyInfoForUserProperty ) ;
302
+ return userProperties . map ( userProperty =>
303
+ getPropertyInfoForUserProperty ( userProperty , parent )
304
+ ) ;
282
305
}
283
306
284
307
function makeValueObjectForUserProperty (
@@ -287,7 +310,7 @@ function makeValueObjectForUserProperty(
287
310
) {
288
311
const valueObject = EezValueObject . create (
289
312
userPropertyValues ,
290
- getPropertyInfoForUserProperty ( userProperty ) ,
313
+ getPropertyInfoForUserProperty ( userProperty , userPropertyValues ) ,
291
314
userPropertyValues . values [ userProperty . id ]
292
315
) ;
293
316
@@ -394,7 +417,10 @@ export const UserPropertyValuesProperty = observer(
394
417
return [ ] ;
395
418
}
396
419
397
- return getUserPropertiesAsPropertyInfos ( flow . userProperties ) ;
420
+ return getUserPropertiesAsPropertyInfos (
421
+ flow . userProperties ,
422
+ object
423
+ ) ;
398
424
}
399
425
400
426
render ( ) {
0 commit comments