PDA

View Full Version : windowinstance.setFrame API behaving inconsistently on client-side



Farratto
January 8th, 2025, 19:33
In coreRPG combat highlighter, it makes a windowinstance.setFrame() call. Generally speaking, this works as expected. But, in an inconsistent manner, it behaves slightly different. On client-side only (never happens on host). If the window in question is scrolled off screen, it will sometimes automatically scroll to the window whose frame is being changed. This is not really a problem. It is just a thing that a user noticed and I was able to track down so I thought I'd let you know.

expected behavior: windowinstance.setFrame API only sets the frame and does not affect scroll position.

observed behavior: Behaves as expected on host. But on client, if windowinstance is scrolled off screen, in addition to expected behavior, it will sometimes scroll to the windowinstance whose frame is being set.

Steps to recreate:

1.> create a campaign with the 5e ruleset.
2.> create and load extension with the following code.
3.> add enough creatures to the CT to where you can scroll some of them off screen.
4.> add those creature's tokens to a map
5.> progress turn so that CT entry 1 is not currently the active turn
6.> connect as client to your new campaign
7.> from the client-side, make sure the CT is scrolled all the way to the bottom some at least one CT entry is completely off screen
8.> mouse-over the token associated with the first CT entry, while observing the CT window for auto-scrolling
9.> repeat steps 7 and 8 several times



fonHover = '';
function onInit()
fonHover = Token.onHover;
Token.onHover = onHoverNew
end
function onHoverNew(target, state)
local ceWindow = nil;
if target then
local nodeCT = CombatManager.getCTFromToken(target);
local combatTrackerWindow = nil;
local windowPath = nil;
local matchingWindow = nil;
if Session.IsHost then
combatTrackerWindow = Interface.findWindow("combattracker_host", "combattracker");
else
combatTrackerWindow = Interface.findWindow("combattracker_client", "combattracker");
end
if combatTrackerWindow then windowPath = combatTrackerWindow.list; end;
if windowPath and nodeCT then
local sNodeID = nodeCT.getPath();
for k,v in pairs(windowPath.getWindows(true)) do
local node = v.getDatabaseNode();
if node.getPath() == sNodeID then
ceWindow = v;
end
end
end
end
if ceWindow then
if state then
ceWindow.setFrame("ctentrybox_active");
else
ceWindow.updateDisplay();
end
end
fonHover(target, state);
end