bug(web): 'kmw.beforekeyboardchange' return type ignored
- Dominant language
- Pascal
- Stars
- 534
- Forks
- 143
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 113
Description
### Describe the bug
Digging into KMW's keyboard-activation code, I noticed some issues about this event:
https://help.keyman.com/DEVELOPER/ENGINE/WEB/15.0/reference/events/kmw.beforekeyboardchange
Note the bit under "Return Value"...
> ### Return Value
> `boolean`
> - `true` if the event should continue processing, `false` if it should not. Your event handler should return `true` aside from exceptional circumstances.
KMW currently ignores it entirely, even before modularization. In fact, it's been this way since at least KMW 2.0:
https://github.com/keymanapp/keyman/blob/75864966f480c2773980faefe3d35021165d6d53/web/source/keymanweb.js#L3122-L3124
https://github.com/keymanapp/keyman/blob/75864966f480c2773980faefe3d35021165d6d53/web/source/keymanweb.js#L3210-L3216
We'd need to condition on the `doBefore...` statements for there to be any effect for `false`. As such, a return value of `false` will not take effect to block a change of keyboard.
----
In discussion with others...
> Let's create an issue to track the bug. Then we can fix it in 17.0, and update the documentation accordingly when ready.
>
> Assuming it's possible to return false and block the change!
This is very much possible for the 'legacy event' type KMW has long supported, based on my analysis of the code.
### Reproduce the bug
_No response_
### Expected behavior
_No response_
### Related issues
_No response_
### Keyman apps
- [ ] Keyman for Android
- [ ] Keyman for iPhone and iPad
- [ ] Keyman for Linux
- [ ] Keyman for macOS
- [ ] Keyman for Windows
- [ ] Keyman Developer
- [ ] KeymanWeb
- [ ] Other - give details at bottom of form
### Keyman version
_No response_
### Operating system
_No response_
### Device
_No response_
### Target application
_No response_
### Browser
_No response_
### Keyboard name
_No response_
### Keyboard version
_No response_
### Language name
_No response_
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.