diff --git a/Toolset/palettes/inspector/editors/com.livecode.pi.customprops.behavior.livecodescript b/Toolset/palettes/inspector/editors/com.livecode.pi.customprops.behavior.livecodescript index eb9a46534b..39066f2cb5 100644 --- a/Toolset/palettes/inspector/editors/com.livecode.pi.customprops.behavior.livecodescript +++ b/Toolset/palettes/inspector/editors/com.livecode.pi.customprops.behavior.livecodescript @@ -1,8 +1,10 @@ script "com.livecode.pi.customprops.behavior" local sPropSet, sHilitePath +local sLastHilite on editorInitialize put empty into sPropSet + set the pathDelimiter of widget "array" of me to numToCodepoint(11) put the editorLabel of me into field "rowlabel" of me set the rowShowLabel of me to false set the label of button "customPropertySet" of group "Set buttons" of me to "customKeys" @@ -66,10 +68,14 @@ on editorUpdate else local tKey fetchArrayDataOnPath tPath, tValue[sPropSet], tKey + set the itemDelimiter to the pathDelimiter of widget "array" of me if the result is empty then - put tKey into field "value" of me - put item -1 of tPath into field "key" of me - select the text of field "key" of me + if the text of field "value" of me is not tKey or \ + the text of field "key" of me is not item -1 of tPath then + put tKey into field "value" of me + put item -1 of tPath into field "key" of me + select the text of field "key" of me + end if else put empty into field "key" of me put empty into field "value" of me @@ -154,6 +160,7 @@ end editorResize on setPropSet pArray local tValue + set the arrayData of widget "array" of me to pArray put the editorValue of me into tValue put pArray into tValue[sPropSet] set the editorValue of me to tValue @@ -162,8 +169,12 @@ end setPropSet on setArrayDataOnPath pValue, pPath, @xArray local tKey + set the itemDelimiter to the pathDelimiter of widget "array" of me put item 1 of pPath into tKey if the number of items in pPath is 1 then + if tKey is not among the keys of xArray then + exit setArrayDataOnPath + end if put pValue into xArray[tKey] else delete item 1 of pPath @@ -173,11 +184,15 @@ end setArrayDataOnPath on setArrayKeyOnPath pKey, pPath, @xArray local tKey + set the itemDelimiter to the pathDelimiter of widget "array" of me put item 1 of pPath into tKey if the number of items in pPath is 1 then + if tKey is not among the keys of xArray then + exit setArrayKeyOnPath + end if local tSubArray - put xArray[item 1 of pPath] into tSubArray - delete variable xArray[item 1 of pPath] + put xArray[tKey] into tSubArray + delete variable xArray[tKey] put tSubArray into xArray[pKey] else delete item 1 of pPath @@ -187,6 +202,7 @@ end setArrayKeyOnPath on deleteArrayKeyOnPath pPath, @xArray local tKey + set the itemDelimiter to the pathDelimiter of widget "array" of me put item 1 of pPath into tKey if the number of items in pPath is 1 then delete variable xArray[item 1 of pPath] @@ -198,6 +214,7 @@ end deleteArrayKeyOnPath on addArrayKeyOnPath pPath, @xArray local tKey + set the itemDelimiter to the pathDelimiter of widget "array" of me put item 1 of pPath into tKey if the number of items in pPath is 1 then put "" into xArray[item 1 of pPath] @@ -209,6 +226,7 @@ end addArrayKeyOnPath on fetchArrayDataOnPath pPath, pArray, @rData local tKey + set the itemDelimiter to the pathDelimiter of widget "array" of me put item 1 of pPath into tKey if the number of items in pPath is 1 then if tKey is not among the keys of pArray then @@ -225,7 +243,9 @@ end fetchArrayDataOnPath on dataChanged checkRehilite - setPropSet the arrayData of widget 1 of me + if not the result then + setPropSet the arrayData of widget 1 of me + end if end dataChanged on valueChanged @@ -237,7 +257,7 @@ end valueChanged private command valueChangedOnPath pPath if pPath is empty then # Don't update anthing - exit valueChangedOnPath + return false end if local tArray put the arrayData of widget 1 of me into tArray @@ -259,6 +279,8 @@ private command valueChangedOnPath pPath end if setArrayDataOnPath field "value" of me, pPath, tArray setPropSet tArray + + return true end valueChangedOnPath on keyChanged @@ -267,17 +289,17 @@ on keyChanged keyChangedOnPath tPath end keyChanged -local sLastHilite private command keyChangedOnPath pPath + set the itemDelimiter to the pathDelimiter of widget "array" of me if pPath is empty then # Don't update anthing - exit keyChangedOnPath + return false end if local tNewKey put field "key" of me into tNewKey if tNewKey is item -1 of pPath then - exit keyChangedOnPath + return false end if local tArray @@ -300,7 +322,10 @@ private command keyChangedOnPath pPath put tNewKey into item -1 of pPath put pPath into sHilitePath + put pPath into sLastHilite unlock screen + + return true end keyChangedOnPath on propSetRenamed pFrom, pTo @@ -378,8 +403,11 @@ end hiliteChanged on checkRehilite # Check to see if the key or value has changed + local tDidUpdate keyChangedOnPath sLastHilite + put the result into tDidUpdate valueChangedOnPath sLastHilite + put the result or tDidUpdate into tDidUpdate # Store the existing hilited path put the hilitedElement of widget "array" of me into sLastHilite @@ -391,6 +419,8 @@ on checkRehilite set the disabled of field "value" of me to sLastHilite is empty set the disabled of field "key" of me to sLastHilite is empty + + return tDidUpdate end checkRehilite function arrayKeysAreNumeric pArrayA diff --git a/notes/bugfix-22113.md b/notes/bugfix-22113.md new file mode 100644 index 0000000000..2958318707 --- /dev/null +++ b/notes/bugfix-22113.md @@ -0,0 +1 @@ +# Fix behavior of custom property inspector when editing a key or adding a new element \ No newline at end of file