I’d like to take some actions whenever a new CartWall page is opened. But there doesn’t seem to be a background script event that does that.
The nearest is OnCartWallPlayerStateChange. It does fire when a specific cart slot on the new page is different - e.g. changes from blank to occupied, so it alters from “empty” to “stopped”. But that’s not always the case.
I should clarify this. OnCartWallPlayerStateChange basically does what it should with respect to changes in player states, as I mentioned before.
The comment (in 6.02) says it also fires when “…the user switches to another page.” I’m not sure that’s always true. I’ve found it doesn’t work :-
If switching between pages with exactly the same players occupied / unoccupied (as they’re all the same state).
If adding a new empty “Untitled” page when the CartWall itself is empty.
When adding multiple empty pages to the above situation.
Perhaps what’s needed is an additional event, something like “OnCartWallPageChange” that specifically looks at pages rather than players.
the main purpose of OnCartwallPlayerStateChange is to push out the state of the players/slots on the current page to external devices, e.g. LEDs on a MIDI controller. So yes, it will not trigger if you switch between pages and the player state remains the same.
Right now, the workaround is to use a timer that looks at Cartwall.GetActivePage:
var
curPage: ICartwallPageControl;
procedure OnTimer;
var
p: ICartwallPageControl;
begin
p := Cartwall.GetActivePage;
if p <> curPage then begin
curPage := p;
// page has changed, do something here
end;
end;
procedure OnLoad;
begin
curPage := nil;
EnableTimer(100); // milliseconds
end;
PS: Received your e-mail while I was away from office, will reply shortly.
end;