Create New Shortcut

Hi

I’m trying to create a new shotcut to MyPaint:
F1 = Brush DEEVAD/LARGE HARD EREASER
All other positions (1 ~ 0) I used with others brushes and I need more (kkkk)…

I try this lines in accelmap.conf, but didnt work…
; (gtk_accel_path “/DocumentActions/Context10s” “F1”)
; (gtk_accel_path “/DocumentActions/Context10” “F1”)
If I open MyPaint didnt work. After close MyPaint and reopen accelmap.conf, this lines above disappear…

Windows 10 #2004
MyPaint v2.0.1

The number of save/restore slots are hard coded in the file gui/document.py, specifically in the method _init_context_actions. To add more slots you would need to change the constant 10 in that function to the number of slots you want, and set up shortcuts for those new slots (since Ctrl+10 is not a valid shortcut).

Also note that:

  • your new lines are commented out (they start with a semicolon)

  • the action names, if they existed, would still have a leading 0 after Context, so instead of Context10 it would be Context010.

So in short, there is unfortunately no easy way to do this yet.

1 Like

Thanks a lot for the feedback…

In the file
…\mingw64\lib\mypaint\gui\document.py
I changed the line 454: (20 instead 10 - just to make a hard test)

450 def _init_context_actions(self):
451 “”“Internal: initializes several brush shortcut-key actions”“”
452 ag = self.action_group
453 context_actions = [ ]
454 for x in range(20):

No more necessary edit accelmap.conf, because now we find all options to change in the Menu Preferences (picture below)

Anyway my accelmap.conf looks like this:

(gtk_accel_path “/DocumentActions/Context010s” “F1”)
(gtk_accel_path “/DocumentActions/Context010” “F1”)
(gtk_accel_path “/WindowActions/OnlineHelpIndex” “”)

The problem: it didn’t work…

Tried other letters than F1, but without success too…
(using 12, instead 20 in for x in range(12) - no success)

I should have tested it to see if there was anything more to it.

You also need to change the constant _NUM_BRUSHKEYS in gui/brushmanager.py to be at least as large as the number you use in gui/documents.py.

That approach will work with up to 99 new bindings, after which some more slight modifications would be required.

Note that when doing mods like this you always run the risk of having a future update screw up your configuration.

1 Like

THANKS A LOT!!!
WORKS!!!

In short we have to make 3 modifications:

1 - Change in def _init_context_actions(self) - …\mingw64\lib\mypaint\gui\document.py
for x in range( XX )
2 - In …\mingw64\lib\mypaint\gui\brushmanager.py use the same number above (XX)
_NUM_BRUSHKEYS = XX
3 - in menu Preferences/Keys configure the key combination

IF POSSIBLE, I would like to request for the next versions of MyPaint that the default are 13 brushes, instead of 10, because normally the keyboard has 13 available keys (especially the blue highlighted)