Giter Club home page Giter Club logo

Comments (8)

kgar avatar kgar commented on July 2, 2024

Initial diagnosis:
When "Focus Visible" becomes active on the roll button, then keydown/keyup bindings do not register with Midi.

That is, if I hold the Adv key and press the roll button, I get the intended Adv roll. If I press any other keys that trigger Focus Visible after that (Shift, for example), then Focus Visibility kicks in, and subsequent attempts at handling keydown at the Foundry level are blocked.

from foundry-vtt-tidy-5e-sheets.

kgar avatar kgar commented on July 2, 2024

In the Foundry source:
image

from foundry-vtt-tidy-5e-sheets.

kgar avatar kgar commented on July 2, 2024

Focused elements prevent keybind events from going through, as an ingrained feature of Foundry.
I will think about how best to approach this problem.

from foundry-vtt-tidy-5e-sheets.

kgar avatar kgar commented on July 2, 2024

After considering a number of options, this approach will allow me to keep the accessibility features while also forwarding keybind events to the KeyboardManager:

On keyup and keydown for relevant Tidy buttons, call

// given ev is a KeyboardEvent
// up is true when a keyup event and false when a keydown event
KeyboardManager.emulateKeypress(
  up, 
  ev.code, 
  {
    altKey: ev.altKey,
    ctrlKey: ev.ctrlKey,
    shiftKey: ev.shiftKey,
    repeat: ev.repeat,
    force: true,
  }
);

This particular logic can be centralized and then referenced by all relevant buttons.
Ideally, I should reach for the svelte-y way to do this across the board, in order to make it more obvious.

from foundry-vtt-tidy-5e-sheets.

kgar avatar kgar commented on July 2, 2024

The above approach, and a variety of others I tried after it, have a number of problems.
Core Foundry functionality and how keybindings work prevents a sheet from having both focused button event handling AND keybinding triggers work in tandem.
The only real fix for this is to revert the majority of my buttons to anchor tags.

from foundry-vtt-tidy-5e-sheets.

kgar avatar kgar commented on July 2, 2024

Reference from Tidy community server: https://discord.com/channels/1167985253072257115/1169792539545587733/1196702693637488660

Midi-QoL leverages the Foundry "Configure Controls" settings to handle Advantage/Disadvantage/some other things. It listens for these key presses while you're on the sheet and clicking a Roll Button, for example.
Meanwhile, when Foundry is deciding whether to trigger the effects of these "Configure Control" keybindings, if it thinks you're focused on an input, like a checkbox or a textbox, it will not trigger keybinding code. For example, if you press Spacebar in a textbox, it doesn't want to toggle Pause/Unpause while you're just trying to type.
As it turns out, because I use buttons for accessibility purposes, Foundry perceives my buttons as inputs that currently have focus, and as a result no Foundry-configured keybindings fire. That means things like Adv/Disadv in Midi-QoL can appear really spotty, not working most of the time, because Foundry thinks I'm focused on an input element and don't want to be bothered...
I've tried a large number of things, even patching the KeyboardManager ( 😱 ). Each different thing I've tried has problems for one reason or another.
In the end, I don't think Foundry wants for there to be buttons all over my sheet.
I may need to change all the buttons back to anchor tags and the like and just throw that whole section of accessibility goals out the window. Like, no tabbing around to things and being able to hit Spacebar to trigger them.
I figure not many people do this, but for the keyboard-focused people, this was really nice to have.
Thing is, I wouldn't expect Midi, for example, to try to do something else than what they're doing. The Configure Controls interface and keybindings are part of Foundry. As I now understand it, this is a place in Foundry where I'm just using it in an unsupported way and have to move it closer to the intended HTML makeup.
As always, I don't know nothing. I could be wrong. I'm always keen for any insight from anyone who might be reading.
I will have to emotionally prepare to migrate a LOT of buttons back to anchors.

from foundry-vtt-tidy-5e-sheets.

kgar avatar kgar commented on July 2, 2024

Now that I've had some time to think about it, I believe this is the way to go about it:

  • Add new Config Setting
    • Name: "Enhanced Keyboard Support"
    • Description: "Enables users to tab through most of the buttons/commands on Tidy 5e Sheets and execute them with conventional button-based keyboard hotkeys. Note: when focused on a button in Foundry, keybindings from "Configure Controls" do not respond. If a module uses this Foundry feature for controls on the sheets, such as using items while holding a special key, then enabling this Tidy 5e Sheets option will interfere with those keybinding."
    • Scope: "World"

Update existing "Classic Default Sheet Behavior" settings to include caveat 'This setting is ignored if "Enhanced Keyboard Support" is turned Off.'

from foundry-vtt-tidy-5e-sheets.

kgar avatar kgar commented on July 2, 2024

Closing as completed.

from foundry-vtt-tidy-5e-sheets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.