Bug?: isValueError property no longer working

Bug?: isValueError property no longer working

SendItCNC
Advocate Advocate
415 Views
2 Replies
Message 1 of 3

Bug?: isValueError property no longer working

SendItCNC
Advocate
Advocate
Looks like the isValueError property on StringValueCommandInput is no longer having the desired effect when set to True from the inputChanged handler (should be that input field turns red and ok button is disabled). Was working before. 

 

Please let me know if I'm off base and there is a way to make this property work as documented.

 

-Dave

 

Here's some relevant code from the inputChanged handler...

 

app = adsk.core.Application.get()

document = app.activeDocument

design = document.products.itemByProductType( 'DesignProductType' )

unitsMgr = design.unitsManager

 

if changed_input.id == 'strId':

    if unitsMgr.isValidExpression(changed_input.value, unitsMgr.defaultLengthUnits):

        realValue = unitsMgr.evaluateExpression(changed_input.value, unitsMgr.defaultLengthUnits)

    else:

        changed_input.isValueError = True

0 Likes
416 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor

I did some testing, and using the isValueError property to change the color works for me. However, it's not affecting the "OK" button being disabled. I moved my validation code from Inputchanged to the ValidateInputs event. Setting the isValueError property is still working here, and I can use the areInputsValid property of the ValidateInputsEventArgs object to control if the "OK" is enabled. 

 

A problem with Fusion updating automatically is that I can't go back and check the behavior in a previous release. Was the "OK" button disabled before when you set isValueError to true? 

 

I've attached a basic script that I used to test it, where you can see the text changing to red. It creates a single StringValueInput and a BoolValueInput. Toggling the state of the BoolValueInput changes if the string is valid or not.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 3

SendItCNC
Advocate
Advocate

@BrianEkins 

 

Brian, thanks for your test case. Running it I see that, if the bool input value is changed then isValueError gets set accordingly and the indeed turns the string input's contents red.

 

However, changing the text in the string input then turns the field contents back to the normal color regardless of the value of the bool that gets assigned to isValueError. So, it appears that the isValueError property is only working when the changed input is not the string input that the property is being set on. That makes it difficult to set isValueError to indicate the validity of the content of a string input.

 

As for the 'Ok' button, IIRC I had to have the string input validation code in the ValidateInputs handler (rather that the InputChanged handler) to get that to behave as expected, as of some months ago. 

0 Likes