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

Cannot return to previous scene control #3

Open
kszczepanskidev opened this issue Jan 4, 2021 · 11 comments
Open

Cannot return to previous scene control #3

kszczepanskidev opened this issue Jan 4, 2021 · 11 comments

Comments

@kszczepanskidev
Copy link

Foundry VTT: 0.7.9
SDR: 1.1.2

When you open the SDR popup you cannot open tool that was selected previously.

Example steps to reproduce:

  1. Select Tile Controls
  2. Select SDR
  3. Try to open Tile Controls again, every other control works; closing the SDR by clicking again doesn't fix anything.
@jopeek
Copy link
Owner

jopeek commented Jan 4, 2021 via email

@kszczepanskidev
Copy link
Author

kszczepanskidev commented Jan 4, 2021

Yeah, I used Tile Controls as an example. For me it seems to be 100% consistent with select control X -> select SDR -> can't open tool x, but other buttons work.

@jopeek
Copy link
Owner

jopeek commented Jan 4, 2021 via email

@kszczepanskidev
Copy link
Author

I've fiddled with it a bit and seems that calling deactivate on the layer helps, but I'm not sure if there are no side effects.

canvas.stage.children.filter(layer => layer._active).forEach(layer => layer.deactivate());

@jopeek
Copy link
Owner

jopeek commented Jan 4, 2021 via email

@jopeek
Copy link
Owner

jopeek commented Jan 4, 2021

I'm going to have to rewrite how SDR is added. It's not currently properly added as a new control but rather hacked into the DOM. That comes with limitations that cause that issue. I'm going to see if I can quickly do this, but if not, this may not be done by me anytime soon.

@kszczepanskidev
Copy link
Author

Yeah, but I think that without hacking the DOM and using proper control items you can't get such nice list with buttons :)

If you want fast solution call this deactivate when opening SDR.

@jopeek
Copy link
Owner

jopeek commented Jan 4, 2021

Good call. Fixed in 1.1.3.

@jopeek jopeek closed this as completed Jan 4, 2021
@TheTural
Copy link

TheTural commented Jan 7, 2021

I'm seeing some variant of this issue still on 1.1.3:

  • Be on the Token Select tool.
    • I can interact with tokens fine.
  • Click SDR and roll a die.
  • My tool selection is returned to the Token Select tool but I cannot interact with any tokens.
    • I can drag a selection box but it does nothing.
  • I also cannot use my mouse wheel to zoom in and out anymore until I switch off to another tool.

Happens 100% reliably on Firefox 84.0.2 and Chrome 87.0.4280.141 with Foundry 0.7.9 and D&D 5e 1.2.1 with no other modules enabled. (All those versions are the most current ones as of right now)

Attached video has other modules enabled but I confirmed it happens with all modules except SDR disabled by creating a brand new world and repeating the test.

2021-01-06.23-10-10-1.mp4

@jopeek
Copy link
Owner

jopeek commented Jan 7, 2021

I rolled back this "fix" because it made things demonstrably worse. I'd rather deal with not having the window close quite as easily than making all scene clicks wonky

@jopeek jopeek reopened this Jan 7, 2021
@kszczepanskidev
Copy link
Author

kszczepanskidev commented Jan 8, 2021

So in my module I've finally ended up with injecting code to the layers activated by the default buttons, which seems to be working far better for me. You can try and test it for yourself (and please test it before updating the module on live 😂 ):

function injectActivationResetForLayers() {
    canvas.stage.children.forEach(layer => {
        defaultActivate = layer.activate;
        layer.activate = function() {
            this.deactivate();
            return defaultActivate.apply(this, arguments);
        };
    });
}

The change to previous solution is that instead always deactivating current layer, we inject code that will deactivate the layer before trying to activate it (layers check if they are active before activating). Other solution could be to just overwrite property _active on the layer so it thinks it's not active, either way it seems to work better and only deselects the tokens when you return to the layer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants