Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 0c4856b

Browse files
committed
[21809] Add function that checks stack name in idelibrary
1 parent eaeeb3f commit 0c4856b

File tree

2 files changed

+30
-22
lines changed

2 files changed

+30
-22
lines changed

Toolset/libraries/revidelibrary.8.livecodescript

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5109,6 +5109,27 @@ private on __setPropertyOfObject pObject, pProperty, pValue
51095109

51105110
end __setPropertyOfObject
51115111

5112+
function ideCheckStackName pName
5113+
if char 1 to 3 of pName is "rev" then
5114+
answer warning revIDELocalise("Using rev in the first three characters of a stack name is reserved for use by the LiveCode development environment and advanced users creating Plug-ins. If you use these characters, your stack may not behave as expected.") with revIDELocalise("OK") and revIDELocalise("Cancel")
5115+
if it is revIDELocalise("Cancel") then
5116+
return false
5117+
end if
5118+
end if
5119+
if pName is a number then
5120+
beep
5121+
answer error revIDELocalise("You cannot set the name of a stack to a number.")
5122+
return false
5123+
end if
5124+
if pName contains quote then
5125+
beep
5126+
answer error revIDELocalise("The name of the stack cannot contain quotes")
5127+
return false
5128+
end if
5129+
5130+
return true
5131+
end ideCheckStackName
5132+
51125133
on revIDEPropertySet pObjectList, pProperty, pValue, pLockUpdates
51135134
local tThrottlePropertyChanged
51145135
put false into tThrottlePropertyChanged
@@ -5130,27 +5151,14 @@ on revIDEPropertySet pObjectList, pProperty, pValue, pLockUpdates
51305151

51315152
# If stack name is changed, use new name when setting edited
51325153
if tStack is tObject and pProperty is "name" then
5133-
local tOldName
5134-
put the short name of tStack into tOldName
5135-
if char 1 to 3 of pValue is "rev" then
5136-
answer warning revIDELocalise("Using rev in the first three characters of a stack name is reserved for use by the LiveCode development environment and advanced users creating Plug-ins. If you use these characters, your stack may not behave as expected.") with revIDELocalise("OK") and revIDELocalise("Cancel")
5137-
if it is revIDELocalise("Cancel") then
5138-
set the name of tStack to tOldName
5139-
exit revIDEPropertySet
5140-
end if
5141-
end if
5142-
if pValue is a number then
5143-
beep
5144-
answer error revIDELocalise("You cannot set the name of a stack to a number.")
5145-
set the name of tStack to tOldName
5146-
exit revIDEPropertySet
5147-
end if
5148-
if pValue contains quote then
5149-
beep
5150-
answer error revIDELocalise("The name of the stack cannot contain quotes")
5154+
5155+
if not ideCheckStackName(pValue) then
5156+
local tOldName
5157+
put the short name of tStack into tOldName
51515158
set the name of tStack to tOldName
51525159
exit revIDEPropertySet
51535160
end if
5161+
51545162
put pValue into tStackName
51555163
else
51565164
put the short name of tStack into tStackName

Toolset/palettes/project browser/behaviors/revideprojectbrowsercontainerrowbehavior.livecodescript

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,10 @@ end mouseDoubleUp
334334

335335
on CloseFieldEditor pFieldEditor, pRow, pKey, pClosingTriggeredBy
336336
# The text the user entered is different than the current value of the target field.
337-
if word 1 of the cObjectLongID of me is "stack" and \
338-
the text of pFieldEditor is a number then
339-
beep
340-
answer error revIDELocalise("You cannot set the name of a stack to a number.")
337+
if word 1 of the cObjectLongID of me is "stack" and \
338+
not ideCheckStackName(the text of pFieldEditor) then
339+
// Force a refresh
340+
set the text of field "name" of me to the text of field "name" of me
341341
exit CloseFieldEditor
342342
end if
343343
set the textColor of field "name" of me to revIDEColor("text_3")

0 commit comments

Comments
 (0)