Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix onTokenMove not being called when lib: tokens are off the Token layer #4363

Merged

Conversation

kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Nov 3, 2023

Identify the Bug or Feature request

Fixes #3581

Description of the Change

The culprit was that the TokensAdded and TokensRemoved events were only be called with Token-layer tokens and not for stamps (difference between Zone.getTokens() vs Zone.getAllTokens()). This has been rectified.

There were several other places that had the same mistake and I've taken the opportunity to update them. As such, there will be slightly different behaviour for those places that have been updated. Changes unlikely to be observed by a user I've marked as [minor], while the others may still not be important but can be easily observed:

  • Application changes:
    • [minor] Pasting a token now checks the new exposed area GUID against all tokens.
    • [minor] Closing the adjust grid tool now updates all tokens.
    • Renaming a token property type will now change the name on all tokens.
    • Renaming a token will now validate the name against all tokens.
  • Macro function changes:
    • [minor] Change to createToken(), copyToken(), and copyTokens() to check the new exposed area GUID against all tokens.
    • Change to test.run() to find test: tokens on all layers.
    • Change to selectTokens() to select on the current layer rather than the Token layer when no parameters are given.
    • Change to getInfo("client") to include lib: and image: tokens not on the Token layer.
  • JS API changes:
    • Change to MapTool.tokens.getMapTokens() to return all tokens, not just those on the token layer.
    • Change to MapTool.clientInfo.libraryTokens() to return all lib: tokens, not just those on the token layer.
  • Web API changes:
    • Change to setProperties handler to find the Zone for a Token even if the Token is not on the Token layer.

Possible Drawbacks

Various bits have slightly different behaviour, can impact frameworks that are relying on functionality being specific to the Token layer.

Documentation Notes

I believe this change actually brings all these bits into alignment with their documentation.

Release Notes

  • Fixed lib: token events and various other behaviours regarding tokens not on the Token layer.

This change is Reviewable

kwvanderlinde and others added 2 commits November 2, 2023 17:46
The culprit was that the `TokensAdded` and `TokensRemoved` events were only be called with Token-layer tokens and not
for stamps (difference between `Zone.getTokens()` vs `Zone.getAllTokens()`). This has been rectified.

There were several other places that had the same mistake and thus have slightly different behaviour now. Changes
unlikely to be observed by a user are marked as [minor], while the others may still not be important but can be easily
observed:
- Application changes:
  - [minor] Pasting a token now checks the new exposed area GUID against all tokens.
  - [minor] Closing the adjust grid tool now updates all tokens.
  - Renaming a token property type will now change the name on all tokens.
  - Renaming a token will now validate the name against all tokens.
- Macro function changes:
  - [minor] Change to `createToken()`, `copyToken()`, and `copyTokens()` to check the new exposed area GUID against all
    tokens.
  - Change to `test.run()` to find `test:` tokens on all layers.
  - Change to `selectTokens()` to select on the current layer rather than the Token layer when no parameters are given.
  - Change to `getInfo("client")` to include `lib:` and `image:` tokens not on the Token layer.
- JS API changes:
  - Change to `MapTool.tokens.getMapTokens()` to return all tokens, not just those on the token layer.
  - Change to `MapTool.clientInfo.libraryTokens()` to return all `lib:` tokens, not just those on the token layer.
- Web API changes:
  - Change to `setProperties` handler to find the `Zone` for a `Token` even if the `Token` is not on the Token layer.
@cwisniew cwisniew added this pull request to the merge queue Nov 3, 2023
Merged via the queue into RPTools:develop with commit 8f19fc5 Nov 3, 2023
4 checks passed
@cwisniew cwisniew added the bug label Nov 3, 2023
@kwvanderlinde kwvanderlinde deleted the bugfix/3581-events-on-hidden-layer branch November 3, 2023 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

[Bug]: Events are not called when Lib-tokens is on the hidden-layer
2 participants