Skip to content

Commit c61097c

Browse files
committed
Update cross_staff_offset.lua
Oops - forgot to re-incorporate a nil-region test.
1 parent 959f590 commit c61097c

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/cross_staff_offset.lua

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function plugindef()
44
finaleplugin.Author = "Carl Vine"
55
finaleplugin.AuthorURL = "http://carlvine.com/lua/"
66
finaleplugin.Copyright = "https://creativecommons.org/licenses/by/4.0/"
7-
finaleplugin.Version = "v1.65" -- with Modeless option
7+
finaleplugin.Version = "v1.66" -- with Modeless option
88
finaleplugin.Date = "2024/07/28"
99
finaleplugin.MinJWLuaVersion = 0.62
1010
finaleplugin.Notes = [[
@@ -80,7 +80,20 @@ local function get_staff_name(staff_num)
8080
return staff_name
8181
end
8282

83-
local function change_offsets()
83+
local function nil_region_error(dialog)
84+
if finenv.Region():IsEmpty() then
85+
local ui = dialog and dialog:CreateChildUI() or finenv.UI()
86+
ui:AlertError(
87+
"Please select some music\nbefore running this script.",
88+
finaleplugin.ScriptGroupName
89+
)
90+
return true
91+
end
92+
return false
93+
end
94+
95+
local function change_offsets(dialog)
96+
if nil_region_error(dialog) then return end
8497
local rgn = finenv.Region()
8598
finenv.StartNewUndoBlock(
8699
string.format("%s %s m.%d-%d",
@@ -227,7 +240,7 @@ local function run_the_dialog()
227240
if submission_error() then
228241
user_error = true
229242
else -- go ahead and change the offsets
230-
change_offsets()
243+
change_offsets(dialog)
231244
end
232245
end)
233246
dialog:RegisterCloseWindow(function(self)
@@ -245,10 +258,11 @@ local function run_the_dialog()
245258
end
246259

247260
local function cross_staff_offset()
261+
if not config.modeless and nil_region_error() then return end
248262
local qim = finenv.QueryInvokedModifierKeys
249263
local shift_key = qim and (qim(finale.CMDMODKEY_ALT) or qim(finale.CMDMODKEY_SHIFT))
250264

251-
if shift_key then
265+
if shift_key then
252266
change_offsets()
253267
else
254268
while run_the_dialog() do end

0 commit comments

Comments
 (0)