[[ Bug 21503 ]] Tree widget - prevent value removal on key addition - #6643
Conversation
Current operation of the tree widget will delete the value stored in a key if the "+" is clicked to add a new sub-key and it is not already an array. This change alters the behavior such that when the "+" is clicked, if the current key is not already an array, then the existing value is moved to the new sub-key that is created.
| variable tArray as Array | ||
| put the empty array into tArray | ||
| put "" into tArray[1 formatted as string] | ||
| put tElement into tArray[1 formatted as string] |
There was a problem hiding this comment.
@bwmilby I wonder if rather than move the element which might be hard to recover from it should check if tElement is empty or not and post an error message if it's not. That way script can handle the message and ask the user if they want to move the current value to an array element. It could be they just clicked + on the wrong line and would like to back out.
There was a problem hiding this comment.
We could I guess add the reverse of this behavior so it's easy to back out but it's not all that intuitive to click the bin on an array element in an array with one key and have the value clobber the array.
There was a problem hiding this comment.
I considered the error route (similar to the delete message) but thought this would be less intrusive for applications. The problem about the reverse is you have a key and a value to deal with so you will lose one anyway.
There was a problem hiding this comment.
Hmm... yeah the way the delete message is done would work rather than a callback. I imagine the main choice people would want to make is between canceling and replacing the element with an array. Using the current element value as array key 1 is possibly more of an edge case... not sure. I guess it could be a third button on the dialog...
answer warning "The array element at path [" & <path> & "] is not empty. Would you like to replace it with an empty array or move it to the first element?" with "Cancel" or "Replace" or "Move"
Adjust code to display a dialog box to allow the user to choose how to handle the situation where a new array could remove an existing value.
|
@livecode-vulcan review ok b70a409 |
|
💙 review by @montegoulding ok b70a409 |
[[ Bug 21503 ]] Tree widget - prevent value removal on key addition Current operation of the tree widget will delete the value stored in a key if the "+" is clicked to add a new sub-key and it is not already an array. This change alters the behavior such that when the "+" is clicked, if the current key is not already an array, then a dialog will ask the user for how to proceed. The options are to `move` the existing value to the new sub-key that is created,`replace` the value with an empty array, or `cancel` the operation.
|
😎 test success b70a409
|
Current operation of the tree widget will delete the value stored in a key
if the "+" is clicked to add a new sub-key and it is not already an array.
This change alters the behavior such that when the "+" is clicked, if the current key is not already an array, then a dialog will ask the user for how to proceed. The options are to
movethe existing value to the new sub-key that is created,replacethe value with an empty array, orcancelthe operation.