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

Commit 0788c59

Browse files
committed
[[ DefaultHandlers ]] Put the caret inside the newly added default handler
When a default handler is added, the user should be able to type right away to add code to that handler. So place the caret accordingly.
1 parent f4914d1 commit 0788c59

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

Toolset/palettes/script editor/behaviors/revsehandlerlistbehavior.livecodescript

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ command resize
259259
unlock screen
260260
end resize
261261

262-
command jumpToHandler pHandler
262+
command jumpToHandler pHandler, pAdded
263263
local tLineNumber
264264
put word 3 of pHandler into tLineNumber
265265

@@ -268,7 +268,7 @@ command jumpToHandler pHandler
268268
set the cChoice of me to tLineNumber & comma & word 2 of pHandler & comma & word 1 of pHandler
269269

270270
if the cCallback of me is not empty then
271-
send the cCallback of me to the cCallbackTarget of me
271+
send the cCallback of me && pAdded to the cCallbackTarget of me
272272
end if
273273

274274
hideGroup
@@ -279,7 +279,10 @@ command closeAccept
279279
local tHandler
280280
put line (the hilitedLine of field "Handlers" of me) of the cHandlers of field "Handlers" of me into tHandler
281281

282+
local tAdded
283+
put false into tAdded
282284
if the number of words in tHandler is 1 then
285+
put true into tAdded
283286
-- Adding a default handler
284287
revSEAddDefaultHandler tHandler
285288
update
@@ -291,7 +294,7 @@ command closeAccept
291294
end if
292295

293296
-- Select the (now) extant handler
294-
jumpToHandler tHandler
297+
jumpToHandler tHandler, tAdded
295298

296299
unlock screen
297300
end closeAccept

Toolset/palettes/script editor/behaviors/revseleftbarbehavior.livecodescript

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ end updateSelectedHandler
9898
# Description
9999
# Callback for the handler list object. This is called when the stack is closed
100100
# which either means the user has chosen a handler, or dismissed the stack.
101-
on handlerSelected
101+
on handlerSelected pNewlyAdded
102102
local tObject
103103
put the long id of group "Left Handler List" of me into tObject
104104

@@ -115,6 +115,11 @@ on handlerSelected
115115
# the handler correctly we call this function which will check if tLine is wrong, and attempt to adjust it.
116116
put seLocateHandler(tHandler, tLine, tType) into tLine
117117

118+
-- If we just added this handler, select at the (empty) line after the handler decl.
119+
if pNewlyAdded then
120+
add 1 to tLine
121+
end if
122+
118123
send "goLine tLine, true" to group "Editor"
119124
seUpdateToolbar
120125
end handlerSelected

0 commit comments

Comments
 (0)