From 8dae72f29d78a9a8a9cbf930b3b4d31388eff3ee Mon Sep 17 00:00:00 2001 From: Monte Goulding Date: Fri, 31 May 2019 13:38:46 +1000 Subject: [PATCH 1/3] [[ Bug ]] Fix custom prop editor when comma is in a key This patch changes the pathDelimiter of the tree view to use vertical tab to reduce the risk of the delimiter being in the key string. Comma is far too likely to be part of the key. Indeed it is in some IDE custom properties. --- .../com.livecode.pi.customprops.behavior.livecodescript | 8 ++++++++ 1 file changed, 8 insertions(+) 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..94da37198c 100644 --- a/Toolset/palettes/inspector/editors/com.livecode.pi.customprops.behavior.livecodescript +++ b/Toolset/palettes/inspector/editors/com.livecode.pi.customprops.behavior.livecodescript @@ -3,6 +3,7 @@ local sPropSet, sHilitePath 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,6 +67,7 @@ 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 @@ -162,6 +164,7 @@ 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 put pValue into xArray[tKey] @@ -173,6 +176,7 @@ 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 local tSubArray @@ -187,6 +191,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 +203,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 +215,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 @@ -269,6 +276,7 @@ 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 From 61249ceaf4f0f3bf8316b10a3e305d10e35adf73 Mon Sep 17 00:00:00 2001 From: Monte Goulding Date: Fri, 31 May 2019 13:41:37 +1000 Subject: [PATCH 2/3] [[ Cleanup ]] Move sLastHilite to top of script Script locals can not be used above their declaration so this patch moves --- .../editors/com.livecode.pi.customprops.behavior.livecodescript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 94da37198c..008ed0d8ce 100644 --- a/Toolset/palettes/inspector/editors/com.livecode.pi.customprops.behavior.livecodescript +++ b/Toolset/palettes/inspector/editors/com.livecode.pi.customprops.behavior.livecodescript @@ -1,5 +1,6 @@ script "com.livecode.pi.customprops.behavior" local sPropSet, sHilitePath +local sLastHilite on editorInitialize put empty into sPropSet @@ -274,7 +275,6 @@ 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 From c32a1cc032992422574178c22d84b3cedb29865c Mon Sep 17 00:00:00 2001 From: Monte Goulding Date: Fri, 31 May 2019 14:34:00 +1000 Subject: [PATCH 3/3] [[ Bug 22113 ]] Fix close field behavior on custom prop PI This patch fixes the behavior of the custom property PI so that close field updates the custom property correctly and the `dataChanged` event from the treeview causes any key or value that is mid-edit to be set. --- ...ode.pi.customprops.behavior.livecodescript | 40 ++++++++++++++----- notes/bugfix-22113.md | 1 + 2 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 notes/bugfix-22113.md 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 008ed0d8ce..39066f2cb5 100644 --- a/Toolset/palettes/inspector/editors/com.livecode.pi.customprops.behavior.livecodescript +++ b/Toolset/palettes/inspector/editors/com.livecode.pi.customprops.behavior.livecodescript @@ -70,9 +70,12 @@ on editorUpdate 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 @@ -157,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 @@ -168,6 +172,9 @@ on setArrayDataOnPath pValue, pPath, @xArray 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 @@ -180,9 +187,12 @@ on setArrayKeyOnPath pKey, pPath, @xArray 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 @@ -233,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 @@ -245,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 @@ -267,6 +279,8 @@ private command valueChangedOnPath pPath end if setArrayDataOnPath field "value" of me, pPath, tArray setPropSet tArray + + return true end valueChangedOnPath on keyChanged @@ -279,13 +293,13 @@ 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 @@ -308,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 @@ -386,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 @@ -399,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