@@ -14,6 +14,7 @@ def __init__(self, ownerComp):
14
14
self .hk_mod = self .ownerComp .op ('null_mod' )
15
15
self .popDialog = self .ownerComp .op ('popDialog' )
16
16
self .__parNumTypes = ['Float' , 'Int' , 'Xy' , 'Xyz' , 'Xyzw' , 'Uv' , 'Uvw' , 'Wh' ,'Rgb' , 'Rgba' ]
17
+ self .__saveParamNameBeforePurge = ''
17
18
18
19
@property
19
20
def Reference (self ):
@@ -289,22 +290,44 @@ def _getTargetPage(self, page_name, target, source_page=None):
289
290
290
291
return new_page
291
292
293
+ def purgeParName (self , text , replace = False ):
294
+
295
+ prune_text = text .replace (' ' , '' )
296
+ # also remove any non-alphanumeric characters
297
+ prune_text = re .sub (r'[^a-zA-Z0-9]' , '' , prune_text )
298
+ # remove leading and trailing underscores
299
+ prune_text = prune_text .strip ('_' )
300
+ # remove any leading numbers
301
+ prune_text = re .sub (r'^[0-9]+' , '' , prune_text )
302
+ text = prune_text .capitalize ()
303
+ if replace :
304
+ paramname = self .popDialog .op ('entry1/inputText' ).par .text
305
+ paramname .val = text
306
+ return text
307
+
308
+
292
309
def OnEditText (self , field , text ):
293
310
if field == 'paramname' :
294
- paramname = self .popDialog .op ('entry2/inputText' ).par .text
295
- prune_text = text .replace (' ' , '' )
296
- # also remove any non-alphanumeric characters
297
- prune_text = re .sub (r'[^a-zA-Z0-9]' , '' , prune_text )
298
- # remove leading and trailing underscores
299
- prune_text = prune_text .strip ('_' )
300
- # remove any leading numbers
301
- prune_text = re .sub (r'^[0-9]+' , '' , prune_text )
302
- text = prune_text .capitalize ()
303
- paramname .val = text
311
+ # we could purge here but that's not how custom par editor works either
312
+ #self.purgeParName(text, replace=True)
313
+ self .__saveParamNameBeforePurge = text
314
+ #self.popDialog.op('entry2/inputText').par.text = text
315
+ pass
304
316
elif field in ['min' , 'max' ]:
305
317
return
306
318
307
-
319
+ def onFocus (self , field , comp ):
320
+ if field == 'label' and self .__saveParamNameBeforePurge and comp .editText == '' :
321
+ self .popDialog .op ('entry2/inputText' ).par .text = self .__saveParamNameBeforePurge
322
+
323
+ def onFocusEnd (self , field , comp ):
324
+ if field == 'paramname' :
325
+ text = comp .editText
326
+ self .__saveParamNameBeforePurge = text
327
+ elif field == 'label' :
328
+ if comp .editText == '' and self .__saveParamNameBeforePurge :
329
+ comp .par .text = self .__saveParamNameBeforePurge
330
+ self .purgeParName (self .__saveParamNameBeforePurge , replace = True )
308
331
309
332
def OnCustomizeParameterDropped (self , dropParam ):
310
333
details = {}
@@ -323,7 +346,7 @@ def OnCustomizeParameterDropped(self, dropParam):
323
346
details ['isNum' ] = is_num
324
347
self .popDialog .par .Minmaxentryarea = is_num
325
348
326
- textEntries = [dropParam .label , dropParam . name .capitalize ()]
349
+ textEntries = [dropParam .name .capitalize (), '' ]
327
350
if is_num :
328
351
textEntries .extend ([dropParam .normMin , dropParam .normMax ])
329
352
textEntries .append (default )
@@ -339,8 +362,12 @@ def OnCustomizeCallback(self, info):
339
362
par = details .get ('par' , None )
340
363
is_num = details .get ('isNum' , False )
341
364
342
- labelEntry = info ['enteredText' ][0 ]
343
- nameEntry = info ['enteredText' ][1 ]
365
+ labelEntry = info ['enteredText' ][1 ]
366
+ nameEntry = info ['enteredText' ][0 ]
367
+
368
+ if not labelEntry :
369
+ labelEntry = nameEntry
370
+ nameEntry = self .purgeParName (nameEntry )
344
371
minEntry = float (info ['enteredText' ][2 ]) if is_num and info ['enteredText' ][2 ] is not None else None
345
372
maxEntry = float (info ['enteredText' ][3 ]) if is_num and info ['enteredText' ][3 ] is not None else None
346
373
chekcboxClamp = info ['checkBoxes' ]
0 commit comments