View Full Version : Trigger Action on Page Load
December 14th, 2006, 07:35 AM
Is there any way of triggering an action(s) when a specific page is loaded in NR2?
I want to reset some variables whenever a certain page is loaded, but I was trying to avoid having to attach the same code to each button that may jump to that page.
December 14th, 2006, 09:17 AM
Yes, you can use the RegisterPanelWatch function for this.
handle = RegisterPanelWatch('JRMC', 'Main', function(group, page, handle) print('Jumped to '..group..'/'..page) end)
Note that either or both of the first two parameters to RegisterPanelWatch may be '*' indicating that it should match any group or page. e.g.
handle1 = RegisterPanelWatch('JRMC', '*', function(g, p, h) end)
handle2 = RegisterPanelWatch('*', 'Main', function(g, p, h) end)
The first of these will call the function whenever any page in the JRMC group is loaded, and the second will call the function whenever any page with the name 'Main' is loaded, regardless of the group.
December 14th, 2006, 03:10 PM
I knew there must be a way, I just couldn't find it!
OK, off to change some code!!
December 19th, 2006, 10:41 PM
I'm obviously doing something wrong here as it's not working, now be easy on me it's my first attempt at lua scripting!
I have the following in the OnCCFLoad function
handle = RegisterPanelWatch('*', 'Library', RP_SetMediaBridgeLibrary(group, page, handle))
And then my function is;
local currlib = NetRemote.GetVariable('MediaBridge.CurrentLibraryR oot')
if (currlib == group) then
print('No library change needed')
elseif (group == "VIDEO") then
elseif (group == "MediaBridge") then
print('No Library Group detected')
The lua console logs;
Monitoring device * and panel Library
Loaded group MediaBridge and page Library
, but my function doesn't get triggered.
December 20th, 2006, 03:20 AM
Try with just the function name ie
handle = RegisterPanelWatch('*', 'Library', RP_SetMediaBridgeLibrary)
December 20th, 2006, 04:18 AM
See told you I was doing something wrong!
That worked. I tried all sorts of other combination, but not that one.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.