diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-06-20 10:55:19 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-06-20 10:55:19 -0400 |
commit | 350225e54ba02a7523e17106936a4ce44af91e55 (patch) | |
tree | 3fa21b7ecfd0ca21ae9e1578d38bbbabe57fdeb8 /indra/newview/scripts/lua | |
parent | 165b3cb04266f96f7fc48f542f915b93a4795aaf (diff) |
Give popup() the ability to not wait; add popup:tip(message).
popup:tip() engages 'SystemMessageTip'.
Diffstat (limited to 'indra/newview/scripts/lua')
-rw-r--r-- | indra/newview/scripts/lua/require/popup.lua | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/indra/newview/scripts/lua/require/popup.lua b/indra/newview/scripts/lua/require/popup.lua index 8a01ab7836..3aaadf85ba 100644 --- a/indra/newview/scripts/lua/require/popup.lua +++ b/indra/newview/scripts/lua/require/popup.lua @@ -1,17 +1,34 @@ local leap = require 'leap' +local mapargs = require 'mapargs' -- notification is any name defined in notifications.xml as -- <notification name=> -- vars is a table providing values for [VAR] substitution keys in the --- notification body. +-- notification body +-- payload prepopulates the response table +-- wait=false means fire and forget, otherwise wait for user response local popup_meta = { -- setting this function as getmetatable(popup).__call() means this gets -- called when a consumer calls popup(notification, vars, payload) - __call = function(self, notification, vars, payload) - return leap.request('LLNotifications', - {op='requestAdd', name=notification, - substitutions=vars, - payload=payload}) + __call = function(self, ...) + local args = mapargs('notification,vars,payload,wait', ...) + -- we use convenience argument names different from 'LLNotifications' + -- listener + args.name = args.notification + args.notification = nil + args.substitutions = args.vars + args.vars = nil + local wait = args.wait + args.wait = nil + args.op = 'requestAdd' + -- Specifically test (wait == false), NOT (not wait), because we treat + -- nil (omitted, default true) differently than false (explicitly + -- DON'T wait). + if wait == false then + leap.send('LLNotifications', args) + else + return leap.request('LLNotifications', args).response + end end } @@ -29,4 +46,8 @@ function popup:alertYesCancel(message) return self('GenericAlertYesCancel', {MESSAGE=message}) end +function popup:tip(message) + self{'SystemMessageTip', {MESSAGE=message}, wait=false} +end + return popup |