Changing keymap with a script doesn't trigger the "is_user_modified" flag #79657
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#79657
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Solus Gnome 4.1
Graphics card: GTX 1050
Blender Version
Broken: 2.83.4, 2.90
Short description of error
I use the Dvorak keyboard layout. I found and modified a script to change all keymaps from QWERTY to DVORAK. When I run the script all keymaps do change, but the ones from addons (both official and 3rd party) don't register as being modified by the user (I believe it's the "is_user_modified" flag, not sure tho).
Here is a screenshot of the Blender keymap before running the script:
Heres is a screenshot of the Blender keymap after running the script:
The red arrows point to a keymap added by Power Sequencer official addon. The green arrows point to a user non-addon keymap. The icon on the right suggesting to restore the keymap doesn't change in the red arrows.
Here's a link to the script: GitHub Link
I also uploaded the script file in case it helps.
Exact steps for others to reproduce the error
To be certain that the problem was caused by 3rd party addons I removed the .config/blender/2.83 folder, started up Blender 2.83.4, activated Power Sequencer addon, pasted the script in a text editor and ran the script.dvorak_script.py
Added subscriber: @AlienTux
This issue was referenced by blender/blender@ada98869df
Added subscriber: @lichtwerk
Changed status from 'Needs Triage' to: 'Confirmed'
Can confirm, will check on this...
Changed status from 'Confirmed' to: 'Needs User Info'
After some digging - when dealing with Addon keymaps - it looks like you have to get the
active
version of the keymap prior to changing the keymapitem.The above is the User configuration stored in
userconf
of thewmWindowManager
.Otherwise you are altering the Addon keymap stored in addonconf of the
wmWindowManager
.[This is the "original" config which you actually want to go back to when you restore a keymap or keymap item]
https://docs.blender.org/api/master/bpy.types.KeyMap.html#bpy.types.KeyMap.active
So this is how it would look, if i do this, I am getting the keymap entry properly tagged
is_user_modified
/KMI_USER_MODIFIED
Does this work for you?
Added subscriber: @brecht
Changed status from 'Needs User Info' to: 'Archived'
Please see the descriptions of the addons and user keymaps:
https://docs.blender.org/api/current/bpy.types.KeyConfigurations.html
Any user configuration should go to the user keymap, which contains items from both builtin functionality and add-ons. Editing the add-ons keymap is not supposed to show up as user modified. Just remove the part of the script that modifies the addons keymap.
I apologize for the late reply.
Thank you @lichtwerk ! That line actually changed everything, but it did require a bit more work.
I added the
km = km.active
, but it caused another problem. My user shortcuts were changed and marked as such (as expected); The add-on shortcuts, however, were changed twice (but were properly marked as modified).I tried reading what @brecht linked, but my python skills are not very good yet. After removing the part that modifies the add-ons keymap it worked fine. (I believe this is what you meant).
In the end I managed to follow a few tutorials to make my own add-on and uploaded it to Github. Added another functionality to allow users to restore all the keymaps to default. Like I said, my python and add-on scripting skills are not very good, but if you have any suggestions to the code here's the link:
https://github.com/AlienTux/blenderScripts
I wanted to add buttons to the preferences window in the add-on manager, but I couldn't figure out how to do it... I also want to add text inputs so anyone can change the layout to anything they want (like AZERTY, QWERTZ, Coleman, etc).
Thank you both for all your help <3